0
0
SQLquery~10 mins

Why normalization matters in SQL - Test Your Understanding

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

Complete the code to select all columns from the table named 'employees'.

SQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
Aemployees
BALL
C*
Dcolumns
Attempts:
3 left
💡 Hint
Common Mistakes
Using the table name instead of '*' to select all columns.
Using 'ALL' which is not valid in this context.
2fill in blank
medium

Complete the code to find duplicate employee names in the 'employees' table.

SQL
SELECT name, COUNT(*) FROM employees GROUP BY name HAVING COUNT(*) [1] 1;
Drag options to blanks, or click blank then click option'
A=
B>
C<=
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' which only finds names appearing exactly once.
Using '<=' which includes names appearing once or less.
3fill in blank
hard

Fix the error in the query to select unique department names from 'employees'.

SQL
SELECT DISTINCT [1] FROM employees;
Drag options to blanks, or click blank then click option'
Adepartment-name
Bdepartment name
CdepartmentName
Ddepartment_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using column names with spaces or dashes without quotes.
Using camelCase when the column uses underscores.
4fill in blank
hard

Fill both blanks to create a query that lists employee names and their department names by joining 'employees' and 'departments'.

SQL
SELECT employees.name, departments.[1] FROM employees JOIN departments ON employees.[2] = departments.id;
Drag options to blanks, or click blank then click option'
Aname
Bdepartment_id
Cid
Ddept_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong column names for join or select.
Mixing up foreign key and primary key columns.
5fill in blank
hard

Fill all three blanks to write a query that counts employees per department, showing department name and count, only for departments with more than 5 employees.

SQL
SELECT departments.[1], COUNT(employees.[2]) FROM employees JOIN departments ON employees.[3] = departments.id GROUP BY departments.[1] HAVING COUNT(employees.[2]) > 5;
Drag options to blanks, or click blank then click option'
Adept_name
Bid
Cdepartment_id
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong columns for counting or joining.
Not grouping by department name.