Aggregates & GROUP BY · Question 9 · Medium

Aggregates & GROUP BY question 9

Table Tickets:
ticket_id | agent | priority
1 | Sana | High
2 | NULL | Low
3 | Sana | Low
4 | NULL | High
5 | Tarun | Low

Some tickets are not yet assigned to an agent. How many rows does this query return?

SELECT agent, COUNT(*)
FROM Tickets
GROUP BY agent;
  1. 2 rows
  2. 3 rows
  3. 4 rows
  4. 5 rows
Answer and explanation

Answer: B. 3 rows

Explanation: GROUP BY puts all NULLs of the grouping column into one group. The groups are Sana, Tarun and NULL (with 2 tickets), so there are 3 rows.

Previous: Table Sales: sale_id | rep | region | amount 1 | Asif | North | 400 2 | Bina |… · Next: Table Attendance: student | subject | month_name | days Pooja | Maths | Jan |…

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

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