Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
We group by the name column to find duplicates of names.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
Grouping by email helps find duplicate email addresses.
3fill in blank
hardFix 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by product_id instead of product_code.
Not using HAVING COUNT(*) > 1 to filter duplicates.
✗ Incorrect
The GROUP BY must be on product_code to find duplicates of product codes.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting username but grouping by user_id or email.
Grouping by a unique column will not find duplicates.
✗ Incorrect
We select and group by username to find duplicates of usernames.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using HAVING COUNT(*) = 1 which finds unique values, not duplicates.
Grouping by a different column than selected.
✗ Incorrect
We select and group by order_number and filter groups having count greater than 1 to find duplicates.