0
0
SQLquery~10 mins

Why query patterns matter 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 employees table.

SQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
AALL
B*
Ceverything
Dcolumns
Attempts:
3 left
💡 Hint
Common Mistakes
Using words like ALL or columns instead of * causes errors.
2fill in blank
medium

Complete the code to filter employees with salary greater than 50000.

SQL
SELECT * FROM employees WHERE salary [1] 50000;
Drag options to blanks, or click blank then click option'
A>
B=
C<
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using = or < will not select the correct rows.
3fill in blank
hard

Fix the error in the query to count employees in each department.

SQL
SELECT department, COUNT([1]) FROM employees GROUP BY department;
Drag options to blanks, or click blank then click option'
Aemployee_id
Bdepartment
Csalary
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Counting a column that can have NULLs leads to wrong counts.
4fill in blank
hard

Fill both blanks to create a query that lists employee names and their salaries, ordered by salary descending.

SQL
SELECT [1], [2] FROM employees ORDER BY salary DESC;
Drag options to blanks, or click blank then click option'
Aname
Bsalary
Cemployee_id
Ddepartment
Attempts:
3 left
💡 Hint
Common Mistakes
Selecting wrong columns will not show the expected data.
5fill in blank
hard

Fill all three blanks to create a query that shows department, average salary, and number of employees, only for departments with more than 5 employees.

SQL
SELECT [1], AVG([2]), COUNT([3]) FROM employees GROUP BY [1] HAVING COUNT([3]) > 5;
Drag options to blanks, or click blank then click option'
Adepartment
Bsalary
C*
Demployee_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong columns in COUNT or GROUP BY causes errors or wrong results.