Bird
0
0

Which of the following SQL queries correctly finds duplicate email values in a table named users?

easy📝 Syntax Q12 of 15
SQL - Advanced Query Patterns
Which of the following SQL queries correctly finds duplicate email values in a table named users?
ASELECT email FROM users GROUP BY email HAVING COUNT(*) > 1;
BSELECT email FROM users WHERE COUNT(email) > 1;
CSELECT email FROM users GROUP BY email WHERE COUNT(*) > 1;
DSELECT email FROM users HAVING COUNT(email) > 1;
Step-by-Step Solution
Solution:
  1. Step 1: Check correct syntax for grouping and filtering

    GROUP BY groups rows; HAVING filters groups. WHERE cannot filter aggregates.
  2. Step 2: Identify correct query

    SELECT email FROM users GROUP BY email HAVING COUNT(*) > 1; uses GROUP BY email and HAVING COUNT(*) > 1 correctly.
  3. Final Answer:

    SELECT email FROM users GROUP BY email HAVING COUNT(*) > 1; -> Option A
  4. Quick Check:

    GROUP BY + HAVING filters duplicates correctly [OK]
Quick Trick: Use HAVING, not WHERE, to filter grouped results [OK]
Common Mistakes:
  • Using WHERE with aggregate functions
  • Placing WHERE after GROUP BY
  • Using COUNT(column) incorrectly in WHERE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes