0
0
PostgreSQLquery~10 mins

ALL, ANY, SOME with subqueries 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 select products with a price greater than all prices in the 'discounts' table.

PostgreSQL
SELECT product_name FROM products WHERE price > [1] (SELECT discount_price FROM discounts);
Drag options to blanks, or click blank then click option'
AALL
BANY
CSOME
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using ANY instead of ALL returns products priced higher than any one discount price, not all.
Using IN is incorrect because it checks for equality, not comparison.
2fill in blank
medium

Complete the code to find employees whose salary is less than or equal to some salaries in the 'managers' table.

PostgreSQL
SELECT employee_name FROM employees WHERE salary <= [1] (SELECT salary FROM managers);
Drag options to blanks, or click blank then click option'
AALL
BIN
CANY
DEXISTS
Attempts:
3 left
💡 Hint
Common Mistakes
Using ALL would require the salary to be less than or equal to every manager's salary, which is stricter.
Using IN checks for equality, not comparison.
3fill in blank
hard

Fix the error in the query to select orders with quantity greater than some quantities in 'order_details'.

PostgreSQL
SELECT order_id FROM orders WHERE quantity > [1] (SELECT quantity FROM order_details);
Drag options to blanks, or click blank then click option'
AALL
BANY
CEXISTS
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using ALL changes the meaning to 'greater than all', which is stricter.
Using IN checks for equality, not comparison.
4fill in blank
hard

Fill both blanks to select customers whose total orders are less than all totals in 'vip_orders'.

PostgreSQL
SELECT customer_id FROM customers WHERE total_orders [1] [2] (SELECT total FROM vip_orders);
Drag options to blanks, or click blank then click option'
A<
B>
CALL
DANY
Attempts:
3 left
💡 Hint
Common Mistakes
Using > ALL would select customers with totals greater than all VIP totals, which is different.
Using ANY changes the meaning to 'less than some', not all.
5fill in blank
hard

Fill all three blanks to select products priced greater than some prices but less than all prices in 'competitor_prices'.

PostgreSQL
SELECT product_name FROM products WHERE price [1] [2] (SELECT price FROM competitor_prices) AND price [3] (SELECT price FROM competitor_prices);
Drag options to blanks, or click blank then click option'
A>
B<
CALL
DANY
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping ALL and ANY changes the logic and results.
Using IN instead of ANY or ALL causes errors or wrong results.