Enrol to start learning
Reading is open to everyone. Enrolling is free, and it is what unlocks the audio lessons, practice tests and progress tracking.
3.2. GROUP BY & HAVING
This section
Practice test
11 questions on this section. Wrong answers show you what to read again.
Sign up to take itWhole chapter
Revision test
Mixed questions from across the chapter. Your answers get marked.
Sign up to take itQuick
Flashcard drill
3 cards from this lesson. Good the night before a test.
Try these first
- 1.
Write an SQL query to count the number of products sold in each category.
Hint
Remember to use GROUP BY after the SELECT statement.
- 2.
How would you find the total number of orders made by each customer?
Hint
You'll need to aggregate by customer ID.
- 3.
What clause do you use to group results based on a specific column?
- HAVING
- GROUP BY
- ORDER BY
Hint
Think about how you would summarize data.
- 4.
True or False: The HAVING clause can be used without GROUP BY.
- True
- False
Hint
Remember what HAVING is designed for.
- 5.
Draft a SQL query that identifies the three products with the highest sales, excluding any product that sold less than 50 units.
Hint
Use GROUP BY and HAVING effectively to filter.
- 6.
Create a comprehensive report using SQL that highlights customer segments based on their number of purchases, categorizing them as 'Low', 'Medium', or 'High' based on thresholds you define.
Hint
You’ll need to use a CASE statement along with GROUP BY and HAVING.
Exercises
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
4 more questions available
Enrol freeQuiz
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting
1 more question available
Enrol freeChallenge Problems
Total Questions
2
Estimated Time
4 min
Passing Score
70%
Instructions
- Read each question carefully
- You can use hints if you need help
- Complete all questions before submitting