From the following table "orders"
order_Id customer amount c001 Riya 500 c002 Rohit 300 c003 Ravi 400
Which query will output the following result?
Total Amount
900
From the following table "orders"
| order_Id | customer | amount |
|---|---|---|
| c001 | Riya | 500 |
| c002 | Rohit | 300 |
| c003 | Ravi | 400 |
Which query will output the following result?
Total Amount
900
Solution
✅ Correct Option: 2
WHERE amount > 300 keeps only the rows with amounts 500 (Riya) and 400 (Ravi). SUM(amount) then adds them:
Option 1: MAX returns the largest value, 500, not the total.
Option 3: ORDER BY only sorts the rows and does not filter them, so SUM adds all three amounts and gives 1200.
Option 4: no amount is below 300 (Rohit's is exactly 300), so no rows match and SUM returns NULL.
Related questions:
2026: 26 May Shift 1
2025: 15 May Shift 2
2026: 21 May Shift 1
2026: 11 May Shift 2