Skip to main contentSkip to solution

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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question