0
0
SQLquery~10 mins

Relational model mental model in SQL - Interactive Code Practice

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

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

SQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
ACOLUMNS
BALL
CEVERY
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using words like ALL or COLUMNS instead of the symbol *.
Forgetting to specify columns or using invalid keywords.
2fill in blank
medium

Complete the SQL query to get only the distinct department names from the 'departments' table.

SQL
SELECT [1] department_name FROM departments;
Drag options to blanks, or click blank then click option'
ADISTINCT
BONLY
CSINGLE
DUNIQUE
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNIQUE instead of DISTINCT in SELECT statements.
Using ONLY or SINGLE which are not valid SQL keywords here.
3fill in blank
hard

Fix the error in the SQL query to count the number of employees in each department.

SQL
SELECT department_id, COUNT([1]) FROM employees GROUP BY department_id;
Drag options to blanks, or click blank then click option'
Aemployee_id
B*
Cdepartment_id
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Counting a specific column that might have NULLs, causing wrong counts.
Using department_id inside COUNT() which counts the group key, not rows.
4fill in blank
hard

Fill both blanks to create a query that finds employees with salary greater than 50000.

SQL
SELECT * FROM employees WHERE salary [1] [2];
Drag options to blanks, or click blank then click option'
A>
B50000
C<
D100000
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than operator instead of greater than.
Using wrong salary values.
5fill in blank
hard

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

SQL
SELECT e.name AS employee_name, d.name AS department_name FROM employees e [1] departments d ON e.[2] = d.[3];
Drag options to blanks, or click blank then click option'
AJOIN
Bdepartment_id
DLEFT
Attempts:
3 left
💡 Hint
Common Mistakes
Using LEFT instead of JOIN without ON clause.
Using wrong column names for joining.