0
0
PostgreSQLquery~10 mins

Returning modified rows with RETURNING in PostgreSQL - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to update the salary of employees and return the updated rows.

PostgreSQL
UPDATE employees SET salary = salary * 1.1 WHERE department = 'Sales' [1] id, salary;
Drag options to blanks, or click blank then click option'
AFETCH
BRETURNING
CSELECT
DOUTPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTPUT instead of RETURNING, which is not valid in PostgreSQL.
Trying to use SELECT after UPDATE without RETURNING.
2fill in blank
medium

Complete the code to delete employees from the Marketing department and return their names.

PostgreSQL
DELETE FROM employees WHERE department = 'Marketing' [1] name;
Drag options to blanks, or click blank then click option'
ARETURNING
BSELECT
CFETCH
DOUTPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTPUT which is not supported in PostgreSQL.
Trying to use SELECT after DELETE without RETURNING.
3fill in blank
hard

Fix the error in the code to insert a new employee and return their id and name.

PostgreSQL
INSERT INTO employees (name, department, salary) VALUES ('Alice', 'HR', 50000) [1] id, name;
Drag options to blanks, or click blank then click option'
AOUTPUT
BFETCH
CSELECT
DRETURNING
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTPUT which is not valid in PostgreSQL.
Trying to use SELECT after INSERT without RETURNING.
4fill in blank
hard

Fill both blanks to update the price of products and return their id and new price.

PostgreSQL
UPDATE products SET price = price [1] 1.2 WHERE category = 'Books' [2] id, price;
Drag options to blanks, or click blank then click option'
A*
B+
CRETURNING
DOUTPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '*' to increase price by percentage.
Using OUTPUT instead of RETURNING.
5fill in blank
hard

Fill all three blanks to insert a new order and return its id, customer_id, and total.

PostgreSQL
INSERT INTO orders (customer_id, total) VALUES ([1], [2]) [3] id, customer_id, total;
Drag options to blanks, or click blank then click option'
A123
B250.75
CRETURNING
DOUTPUT
Attempts:
3 left
💡 Hint
Common Mistakes
Using OUTPUT instead of RETURNING.
Putting quotes around numeric values.