From the table 'Orders' below:
order_Id customer_Id order_date amount 1 101 2024-03-01 2500 2 102 2024-03-01 12000 3 101 2024-03-31 3000 4 103 2024-04-01 4500 5 102 2024-04-30 8000
Which query will retrieve the total amount from 'Orders' made by customer_Id = 101 in the month of March 2024.
From the table 'Orders' below:
| order_Id | customer_Id | order_date | amount |
|---|---|---|---|
| 1 | 101 | 2024-03-01 | 2500 |
| 2 | 102 | 2024-03-01 | 12000 |
| 3 | 101 | 2024-03-31 | 3000 |
| 4 | 103 | 2024-04-01 | 4500 |
| 5 | 102 | 2024-04-30 | 8000 |
Which query will retrieve the total amount from 'Orders' made by customer_Id = 101 in the month of March 2024.
Solution
Option 3 uses SUM(amount) to return a single total, reads from the Orders table with FROM, and filters rows to customer 101 in March 2024 using MONTH(order_date) = 3 AND YEAR(order_date) = 2024.
For customer 101 this picks orders 1 and 3, so the result is .
Option 1: it has no FROM clause, so the query is invalid, even though the date range itself is correct.
Option 2: it returns individual amounts instead of a total, and the range ends at '2024-04-31', which is not a real date.
Option 4: the filter is correct, but it has no SUM, so it lists amounts (2500 and 3000) rather than the total.
Related questions:
2025: 30 May Shift 2
2026: 23 May Shift 2
2025: 16 May Shift 1
2025: 20 May Shift 1