0
0
PostgreSQLquery~10 mins

Why PostgreSQL over other databases - 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 a table named employees.

PostgreSQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
A*
Ball
Ceverything
Dcolumns
Attempts:
3 left
💡 Hint
Common Mistakes
Using words like 'all' or 'columns' instead of the symbol *.
Leaving the blank empty.
2fill in blank
medium

Complete 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'
A<=
B<
C=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using < or <= which select smaller or equal values.
Using = which selects only equal values.
3fill in blank
hard

Fix 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'
Asalary
B*
Cdepartment
Demployee_id
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.
4fill in blank
hard

Fill 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'
ASERIAL
BVARCHAR(100)
CINTEGER
DTEXT
Attempts:
3 left
💡 Hint
Common Mistakes
Using TEXT for id which does not auto-increment.
Using INTEGER for name which is not text.
5fill in blank
hard

Fill 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'
A50000
B60000
C10
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong salary value.
Using wrong comparison operator.
Swapping id and salary values.