SQL Group By Clause - Group by Clause in SQL
Demo wikitechydatabase
- Below is a selection from the wikitechytable table used in the examples:
The SQL GROUP BY Statement
- The GROUP BY statement groups rows that have the same values into summary rows, like "find the number of wikitechytable in each gender".
- The GROUP BY statement is often used with aggregate functions (COUNT(), MAX(), MIN(), SUM(), AVG()) to group the result-set by one or more columns.
GROUP BY Syntax
SELECT column_name(s) FROM table_name GROUP BY column_name(s) ORDER BY column_name(s);
SQL GROUP BY Examples
- The following SQL statement lists the number of wikitechytable in each gender:
SELECT COUNT(id), gender FROM wikitechytable GROUP BY gender