Table-ProductsSale:
ID Product Price 101 A 100 102 B 55 103 C 55 104 D 65 105 E 35
Which query should be used to retrieve the total price from the table for products which have price greater than 55?
Table-ProductsSale:
| ID | Product | Price |
|---|---|---|
| 101 | A | 100 |
| 102 | B | 55 |
| 103 | C | 55 |
| 104 | D | 65 |
| 105 | E | 35 |
Which query should be used to retrieve the total price from the table for products which have price greater than 55?
Solution
SUM(Price) adds up the values in the Price column, and WHERE Price > 55 filters the rows before the sum is taken. Only products A (100) and D (65) have a price greater than 55, so the query returns .
Option 2: SUM(Product) is wrong because Product holds text, not numbers. HAVING also needs GROUP BY and is meant for conditions on groups, not for filtering rows.
Option 3: GROUP BY only groups rows and does not add them up, so it gives no total.
Option 4: DISTINCT only removes duplicates, and Price >= 55 would also include B and C. It returns product names, not a total.
Related questions:
2026: 29 May Shift 1
2025: 27 May Shift 2
2025: 22 May Shift 1
2025: 15 May Shift 2
2025: 13 May Shift 2