0
0
SQLquery~10 mins

Finding duplicates efficiently in SQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select duplicate names from the users table.

SQL
SELECT name, COUNT(*) FROM users GROUP BY [1] HAVING COUNT(*) > 1;
Drag options to blanks, or click blank then click option'
Aemail
Bid
Cname
Dage
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by a unique column like id will never find duplicates.
Forgetting to use HAVING COUNT(*) > 1 to filter duplicates.
2fill in blank
medium

Complete the code to find duplicate emails in the customers table.

SQL
SELECT email, COUNT(*) FROM customers GROUP BY [1] HAVING COUNT(*) > 1;
Drag options to blanks, or click blank then click option'
Aemail
Bcustomer_id
Cphone
Daddress
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by a unique identifier like customer_id will not find duplicates.
Not using HAVING clause to filter groups with more than one row.
3fill in blank
hard

Fix the error in the code to find duplicate product codes in the inventory table.

SQL
SELECT product_code, COUNT(*) FROM inventory GROUP BY [1] HAVING COUNT(*) > 1;
Drag options to blanks, or click blank then click option'
Aproduct_id
Bquantity
Cprice
Dproduct_code
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by product_id instead of product_code.
Not using HAVING COUNT(*) > 1 to filter duplicates.
4fill in blank
hard

Fill both blanks to find duplicate usernames and count them in the accounts table.

SQL
SELECT [1], COUNT(*) FROM accounts GROUP BY [2] HAVING COUNT(*) > 1;
Drag options to blanks, or click blank then click option'
Ausername
Buser_id
Demail
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting username but grouping by user_id or email.
Grouping by a unique column will not find duplicates.
5fill in blank
hard

Fill all three blanks to find duplicate order numbers and their counts in the orders table.

SQL
SELECT [1], COUNT(*) FROM orders GROUP BY [2] HAVING COUNT(*) [3] 1;
Drag options to blanks, or click blank then click option'
Aorder_number
B>
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using HAVING COUNT(*) = 1 which finds unique values, not duplicates.
Grouping by a different column than selected.