0
0
DBMS Theoryknowledge~10 mins

SELECT with WHERE, ORDER BY, GROUP BY in DBMS Theory - 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 all columns from the table named 'employees'.

DBMS Theory
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
Acolumns
BALL
C*
Deverything
Attempts:
3 left
💡 Hint
Common Mistakes
Writing 'ALL' instead of '*'
Using 'columns' which is not valid SQL syntax
2fill in blank
medium

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

DBMS Theory
SELECT name, salary 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 '<' which selects salaries less than 50000
Using '=' which selects salaries exactly 50000
3fill in blank
hard

Fix the error in the code to order employees by their hire date in ascending order.

DBMS Theory
SELECT name, hire_date FROM employees ORDER BY hire_date [1];
Drag options to blanks, or click blank then click option'
AUP
BDESC
CDOWN
DASC
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'DESC' which sorts in descending order
Using 'UP' or 'DOWN' which are not valid SQL keywords
4fill in blank
hard

Fill both blanks to group employees by department and count how many are in each.

DBMS Theory
SELECT [1], COUNT(*) FROM employees GROUP BY [2];
Drag options to blanks, or click blank then click option'
Adepartment
Bsalary
Cdepartment_id
Dname
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by 'name' which is unique per employee
Selecting 'salary' which is not a grouping column
5fill in blank
hard

Fill all three blanks to select department names, average salary, and order results by average salary descending.

DBMS Theory
SELECT [1], AVG([2]) FROM employees GROUP BY [3] ORDER BY AVG(salary) DESC;
Drag options to blanks, or click blank then click option'
Adepartment_name
Bsalary
Demployee_id
Attempts:
3 left
💡 Hint
Common Mistakes
Grouping by employee_id which is unique per row
Averaging department_name which is not numeric