Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to select all columns from a table named employees.
PostgreSQL
SELECT [1] FROM employees; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using words like 'all' or 'columns' instead of the symbol *.
Leaving the blank empty.
✗ Incorrect
In SQL, * means select all columns from the table.
2fill in blank
mediumComplete the code to filter employees with salary greater than 50000.
PostgreSQL
SELECT * FROM employees WHERE salary [1] 50000;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using < or <= which select smaller or equal values.
Using = which selects only equal values.
✗ Incorrect
The symbol > means 'greater than' in SQL conditions.
3fill in blank
hardFix the error in the code to count employees in each department.
PostgreSQL
SELECT department, COUNT([1]) FROM employees GROUP BY department; Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Counting a specific column which may have NULLs and cause wrong counts.
Using a column that is not unique or relevant.
✗ Incorrect
Using COUNT(*) counts all rows in each group, which is standard for counting employees.
4fill in blank
hardFill both blanks to create a table named products with id as primary key.
PostgreSQL
CREATE TABLE products (id [1] PRIMARY KEY, name [2] NOT NULL);
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using TEXT for id which does not auto-increment.
Using INTEGER for name which is not text.
✗ Incorrect
SERIAL creates an auto-incrementing integer for id. VARCHAR(100) defines a text column with max 100 characters for name.
5fill in blank
hardFill all three blanks to update the salary of employee with id 10 to 60000.
PostgreSQL
UPDATE employees SET salary = [1] WHERE id [2] [3];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong salary value.
Using wrong comparison operator.
Swapping id and salary values.
✗ Incorrect
We set salary to 60000, and use = to match employee with id 10.