The GROUP BY clause in SQL is used to aggregate data across rows that share common values. It’s commonly used with functions like COUNT(), SUM(), AVG(), MIN(), and MAX() to group results by one or more columns for meaningful summaries and reports.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
What is the primary use of the GROUP BY clause in SQL?
Correct
Incorrect
Question 2 of 15
2. Question
Which function is most commonly used with GROUP BY?
Correct
Incorrect
Question 3 of 15
3. Question
What will the following query return?
SELECT department, COUNT(*) FROM employees GROUP BY department;
Correct
Incorrect
Question 4 of 15
4. Question
Which clause should come after `GROUP BY` in a SQL query?
Correct
Incorrect
Question 5 of 15
5. Question
What happens if a column in the SELECT clause is not in `GROUP BY` or inside an aggregate function?
Correct
Incorrect
Question 6 of 15
6. Question
Which query shows the highest salary in each department?
Correct
Incorrect
Question 7 of 15
7. Question
What does `GROUP BY 1` mean in this query?
SELECT city, COUNT(*) FROM customers GROUP BY 1;
Correct
Incorrect
Question 8 of 15
8. Question
Which of the following is TRUE about `HAVING` clause?
Correct
Incorrect
Question 9 of 15
9. Question
What is the output of this query?
SELECT COUNT(*), country FROM users GROUP BY country;
Correct
Incorrect
Question 10 of 15
10. Question
Can you use multiple columns in `GROUP BY`?
Correct
Incorrect
Question 11 of 15
11. Question
What happens if there is no `GROUP BY` but you use an aggregate function?
Correct
Incorrect
Question 12 of 15
12. Question
Which of these is invalid?
SELECT department, SUM(salary) FROM employees WHERE salary > 30000 GROUP BY department;
Correct
Incorrect
Question 13 of 15
13. Question
What’s the correct clause to filter grouped results?
SELECT department, AVG(salary) FROM employees GROUP BY department ??? AVG(salary) > 50000;
Correct
Incorrect
Question 14 of 15
14. Question
Which query shows the number of products sold per category?
Correct
Incorrect
Question 15 of 15
15. Question
What is the default sorting behavior of `GROUP BY` in SQL?
Correct
Incorrect
Summary
The “GROUP BY” clause in SQL is a fundamental tool for summarizing and aggregating data. It works in tandem with functions like `SUM()`, `COUNT()`, and `AVG()`, and enables insights grouped by categories like department, region, or customer. Mastering `GROUP BY` is essential for anyone building reports or analytics in SQL.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.