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

Similar Programs Chapter Last Updated
SQL Query To List All Databases SQL Commands 17-04-2023
SQL Query To Find Duplicate Records SQL Commands 17-04-2023
How To Create Procedure In SQL SQL Commands 24-03-2023
Substring In SQL SQL Commands 27-11-2019
SQL SELECT Statement SQL Commands 16-03-2018

1