Aggregates & GROUP BY · Question 11 · Medium
Aggregates & GROUP BY question 11
Table Sales:
sale_id | rep | region | amount
1 | Asif | North | 400
2 | Bina | South | 250
3 | Asif | North | NULL
4 | Chirag | South | 550
5 | Bina | West | 300
6 | Deepa | North | 600
7 | Chirag | South | 250
What does this query return?
SELECT region, SUM(amount)
FROM Sales
WHERE amount > 250
GROUP BY region
HAVING SUM(amount) >= 550
ORDER BY region;
- North, 1000; South, 550
- North, 1000; South, 1050
- North, 1000
- North, 1000; South, 550; West, 300
Answer and explanation
Answer: A. North, 1000; South, 550
Explanation: WHERE first removes the two 250 sales and the NULL. The groups are then North 400 + 600 = 1000, South 550 and West 300, and HAVING keeps the sums that are at least 550.
Previous: Table Attendance: student | subject | month_name | days Pooja | Maths | Jan |… · Next: Table Innings: inn_id | batter | team | runs 1 | Kunal | Tigers | 45 2 | Kunal…
Practise aggregates & group by
Try a fresh set of aggregates & group by questions with an explanation after every answer, free and without signing up: Aggregates & GROUP BY practice. Or sit a full placement mock test.
More aggregates & group by questions
- Table Sales: sale_id | rep | region | amount 1 | Asif | North | 400 2 | Bina |…
- Table Tickets: ticket_id | agent | priority 1 | Sana | High 2 | NULL | Low 3 |…
- Table Attendance: student | subject | month_name | days Pooja | Maths | Jan |…
- Table Innings: inn_id | batter | team | runs 1 | Kunal | Tigers | 45 2 | Kunal…
- A table Sales(sale_id, rep, region, amount) is given. Which query lists the…
- Table Sales: sale_id | rep | region | amount 1 | Asif | North | 400 2 | Bina |…
- Table Attendance: student | subject | month_name | days Pooja | Maths | Jan |…
- Table Sales: sale_id | rep | region | amount 1 | Asif | North | 400 2 | Bina |…
- Table Sales: sale_id | rep | region | amount 1 | Asif | North | 400 2 | Bina |…
- Table Innings: inn_id | batter | team | runs 1 | Kunal | Tigers | 45 2 | Kunal…
More sql practice
Subqueries & CTEs · Window Functions · NULL Handling · SQL Functions & CASE · UNION, INTERSECT & EXCEPT · Tables, Keys & Constraints · DML & Transactions · SELECT, WHERE & ORDER BY
LogicWiz Exams home · All practice topics · Placement mock tests · Daily 10 challenge