Complete the code to count how many orders have a total price greater than 100.
SELECT COUNT(CASE WHEN total_price [1] 100 THEN 1 END) AS high_value_orders FROM orders;
The query counts orders where total_price is greater than 100 using a CASE inside COUNT.
Complete the code to sum the total_price only for orders where status is 'completed'.
SELECT SUM(CASE WHEN status = 'completed' THEN [1] ELSE 0 END) AS completed_total FROM orders;
The CASE returns total_price for completed orders, else 0, so SUM adds only completed orders' prices.
Fix the error in the query to count orders with discount applied (discount > 0).
SELECT COUNT(CASE WHEN discount [1] 0 THEN 1 END) AS discounted_orders FROM orders;
SQL uses a single > for greater than, not ==. So use discount > 0 to count discounted orders.
Fill both blanks to calculate average price for 'shipped' orders only.
SELECT AVG(CASE WHEN status [1] 'shipped' THEN [2] ELSE NULL END) AS avg_shipped_price FROM orders;
The CASE checks if status equals 'shipped' and returns total_price to average only those orders.
Fill all three blanks to count orders with priority 'high' and total_price over 200.
SELECT COUNT(CASE WHEN priority [1] 'high' AND total_price [2] [3] THEN 1 END) AS high_value_high_priority FROM orders;
The CASE counts orders where priority equals 'high' and total_price is greater than 200.