Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to select all columns from the table named 'employees'.
MySQL
SELECT [1] FROM employees; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Writing 'ALL' instead of '*'
Using words like 'columns' or 'everything' which are not valid SQL keywords
✗ Incorrect
Using * selects all columns from the table.
2fill in blank
mediumComplete the code to filter employees whose age is greater than 30.
MySQL
SELECT * FROM employees WHERE age [1] 30;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' which means less than
Using '=' which means equal to
✗ Incorrect
The '>' operator filters rows where age is greater than 30.
3fill in blank
hardFix the error in the code to count the number of employees.
MySQL
SELECT COUNT([1]) FROM employees; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Counting a specific column which may ignore NULL values
Using a column name instead of '*'
✗ Incorrect
Using COUNT(*) counts all rows regardless of column values.
4fill in blank
hardFill both blanks to select distinct departments and order them alphabetically.
MySQL
SELECT [1] department FROM employees ORDER BY department [2];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using ALL instead of DISTINCT
Ordering with DESC which sorts in reverse alphabetical order
✗ Incorrect
DISTINCT selects unique departments, and ASC orders them from A to Z.
5fill in blank
hardFill all three blanks to create a new table named 'departments' with columns 'id' as integer primary key and 'name' as text.
MySQL
CREATE TABLE [1] ([2] INT PRIMARY KEY, [3] TEXT);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong table name like 'employees'
Swapping column names or missing PRIMARY KEY
✗ Incorrect
This creates a table called 'departments' with 'id' as an integer primary key and 'name' as a text column.