0
0
PostgreSQLquery~10 mins

Why result control matters in PostgreSQL - 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.

PostgreSQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
AALL_COLUMNS
BALL
CANY
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using ALL or ANY instead of *
Trying to write ALL_COLUMNS which is not valid SQL
2fill in blank
medium

Complete the code to get only unique department names from the departments table.

PostgreSQL
SELECT [1] department_name FROM departments;
Drag options to blanks, or click blank then click option'
ADISTINCT
BUNIQUE
CSINGLE
DONLY
Attempts:
3 left
💡 Hint
Common Mistakes
Using UNIQUE which is not a valid SQL keyword here
Using ONLY which is not a SQL keyword
3fill in blank
hard

Fix the error in the query to order employees by salary descending.

PostgreSQL
SELECT * FROM employees ORDER BY salary [1];
Drag options to blanks, or click blank then click option'
AASC
BDOWN
CDESC
DBACK
Attempts:
3 left
💡 Hint
Common Mistakes
Using ASC which orders ascending
Using DOWN or BACK which are not valid SQL keywords
4fill in blank
hard

Fill both blanks to select employee names and salaries where salary is greater than 50000.

PostgreSQL
SELECT employee_name, salary FROM employees WHERE salary [1] [2];
Drag options to blanks, or click blank then click option'
A>
B50000
C<
D100000
Attempts:
3 left
💡 Hint
Common Mistakes
Using less than operator < instead of >
Using 100000 instead of 50000
5fill in blank
hard

Fill all three blanks to create a query that selects department names and counts employees, grouping by department and showing only groups with more than 5 employees.

PostgreSQL
SELECT [1], COUNT(*) FROM employees GROUP BY [2] HAVING COUNT(*) [3] 5;
Drag options to blanks, or click blank then click option'
Adepartment_name
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using different columns in SELECT and GROUP BY
Using less than operator < in HAVING clause