Group By In SQL
Chapter:
SQL Commands
Last Updated:
12-11-2020 19:40:59 UTC
Program:
/* ............... START ............... */
SELECT col1,col2
FROM table
WHERE conditions
GROUP BY col1,col2
SELECT col1,count(*)
FROM table
WHERE conditions
GROUP BY column1
/* ............... END ............... */
Output
Notes:
-
Group By is used to group the row having the same value like "Group by age of person"
- The GROUP BY statement is often used with aggregate functions.
- Mostly used aggregate function in group by is COUNT, MAX, MIN, SUM, AVG
Tags
SQL Group By, GROUP BY clause, How to use group by in SQL