📖
Theory
Understand the concept step by step
GROUP BY groups rows that have the same values in specified columns.
It is commonly used with aggregate functions such as COUNT, SUM and AVG.
💻
Example
See how the concept works in SQL
SQL
SELECT department, COUNT(*) AS employees
FROM employees
GROUP BY department;📤
Output
Understand what the query produces
The query returns the number of employees in each department.
📝
Practice
Test your understanding
Count how many products belong to each category.
❓
MCQs
Check your SQL knowledge
What is the main concept covered in GROUP BY?
A.Groups rows for aggregation
B.Deletes groups
C.Creates databases
D.Sorts only columns
💼
Interview Questions
Prepare for SQL interviews
1
Interview Question
What is GROUP BY?
2
Interview Question
Why is GROUP BY used with aggregate functions?
3
Interview Question
What happens when rows have the same grouping value?