Which of the following SQL query will filter products (ProductName) having Cost more than 1000 from the table PRODUCTS?
Which of the following SQL query will filter products (ProductName) having Cost more than 1000 from the table PRODUCTS?
Solution
The WHERE clause filters individual rows before they are returned. is a row-level condition, so SELECT ProductName FROM PRODUCTS WHERE Cost>1000; returns the names of products costing more than 1000.
Options 3 and 4: HAVING filters groups after GROUP BY (usually with aggregate functions like SUM or COUNT). It is not meant for plain row conditions, and without GROUP BY a non-aggregated column like Cost in HAVING is invalid in standard SQL.
Option 2: GROUP BY only groups rows. It does not filter them, and a condition like Cost>1000 is not a valid grouping column.
Related questions:
2026: 24 May Shift 1
2026: 29 May Shift 2
2025: 14 May Shift 1
2026: 26 May Shift 1