Bird
0
0

Consider the table attendance with columns class, student, and date. What does this query return?

medium📝 query result Q5 of 15
SQL - GROUP BY and HAVING
Consider the table attendance with columns class, student, and date. What does this query return?

SELECT class, date, COUNT(student) FROM attendance GROUP BY class, date;
ANumber of students per class per date
BNumber of classes per student per date
CNumber of dates per class per student
DTotal students in the attendance table
Step-by-Step Solution
Solution:
  1. Step 1: Identify grouping columns

    The query groups rows by class and date, so each group is a unique class-date pair.
  2. Step 2: Understand COUNT(student)

    COUNT(student) counts how many students attended each class on each date.
  3. Final Answer:

    Number of students per class per date -> Option A
  4. Quick Check:

    COUNT with GROUP BY multiple columns counts per unique pairs [OK]
Quick Trick: COUNT with GROUP BY multiple columns counts per group [OK]
Common Mistakes:
MISTAKES
  • Mixing grouping columns order
  • Misinterpreting COUNT as total table count
  • Confusing columns in SELECT and GROUP BY

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes