Bird
0
0

Given the table employees with columns id and email, what will this query return? SELECT email FROM employees GROUP BY email HAVING COUNT(*) > 1;

medium📝 query result Q4 of 15
SQL - Advanced Query Patterns
Given the table employees with columns id and email, what will this query return? SELECT email FROM employees GROUP BY email HAVING COUNT(*) > 1;
AAll emails including unique ones
BAll emails that appear more than once in employees
CSyntax error due to missing WHERE clause
DOnly one email from the table
Step-by-Step Solution
Solution:
  1. Step 1: Understand GROUP BY with HAVING COUNT(*) > 1

    This query groups rows by email and filters groups with more than one row, i.e., duplicates.
  2. Step 2: Determine the output

    The query returns emails that appear multiple times in the employees table.
  3. Final Answer:

    All emails that appear more than once in employees -> Option B
  4. Quick Check:

    HAVING COUNT(*) > 1 filters duplicates [OK]
Quick Trick: HAVING filters groups after grouping, unlike WHERE [OK]
Common Mistakes:
  • Thinking WHERE filters groups
  • Assuming unique emails are included
  • Expecting syntax error without WHERE

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SQL Quizzes