Which clause is used to filter rows in query results?

Study for the SQL Basics Test. Improve your knowledge with multiple choice questions and detailed explanations. Prepare effectively to master SQL concepts!

Multiple Choice

Which clause is used to filter rows in query results?

Explanation:
Filtering rows in the results is done with the WHERE clause. It applies a condition to each row and only keeps the rows that satisfy that condition, before any grouping or calculations take place. For example, SELECT id, name FROM customers WHERE country = 'US' AND status = 'active' returns only active customers from the US. Other clauses have different roles: FROM identifies the table or source of data; GROUP BY collects rows into groups for aggregation; HAVING filters those groups after aggregation. If you’re filtering individual rows without grouping, WHERE is the right tool.

Filtering rows in the results is done with the WHERE clause. It applies a condition to each row and only keeps the rows that satisfy that condition, before any grouping or calculations take place. For example, SELECT id, name FROM customers WHERE country = 'US' AND status = 'active' returns only active customers from the US.

Other clauses have different roles: FROM identifies the table or source of data; GROUP BY collects rows into groups for aggregation; HAVING filters those groups after aggregation. If you’re filtering individual rows without grouping, WHERE is the right tool.

Subscribe

Get the latest from Passetra

You can unsubscribe at any time. Read our privacy policy