Which of the following SQL query will filter products having cost more than 500?
Which of the following SQL query will filter products having cost more than 500?
Solution
✅ Correct Option: 1
The WHERE clause filters individual rows before any grouping. So SELECT ProductName FROM PRODUCTS WHERE Cost>500; returns only the products whose cost is greater than 500.
Options 3 and 4: HAVING filters groups after GROUP BY, and it needs a GROUP BY or an aggregate. Without one, it is not the standard way to filter rows, and Cost is not an aggregated or grouped column here.
Option 2: GROUP BY only groups rows. It does not filter them, and it cannot take a condition like Cost>500.
Related questions:
2026: 20 May Shift 1
2025: 15 May Shift 2
2025: 21 May Shift 1
2026: 31 May Shift 1