Aggregates & GROUP BY · Question 3 · Easy

A table Sales(sale_id, rep, region, amount) has no NULL in region. Which expression gives the number of different regions in the table?

  1. COUNT(region)
  2. COUNT(DISTINCT region)
  3. DISTINCT COUNT(region)
  4. SUM(DISTINCT region)
Answer and explanation

Answer: B. COUNT(DISTINCT region)

Explanation: COUNT(region) counts every row with a region, repeats included. Putting DISTINCT inside the brackets counts each different value once.

Previous: Table Sales: sale_id | rep | region | amount 1 | Asif | North | 400 2 | Bina |… · 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

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