What is the purpose of the WHERE clause in SQL?
A
To sort query results B
To group rows C
To filter rows based on conditions D
To join tables
Analysis & Theory
The WHERE clause filters rows that meet specified conditions.
Which query selects employees with a salary greater than 5000?
A
SELECT * FROM employees WHERE salary > 5000; B
SELECT * FROM employees HAVING salary > 5000; C
SELECT * FROM employees ORDER BY salary > 5000; D
SELECT * FROM employees FILTER salary > 5000;
Analysis & Theory
WHERE filters rows by the specified condition.
Which operator checks if a value is equal to another in the WHERE clause?
A
== B
=== C
= D
EQUAL
Analysis & Theory
In SQL, the = operator tests equality.
Which keyword is used to filter rows where a column value is NULL?
A
WHERE column = NULL B
WHERE column IS NULL C
WHERE column == NULL D
WHERE NULL column
Analysis & Theory
Use IS NULL to check for NULL values.
How do you select rows where 'status' is either 'Active' or 'Pending'?
A
WHERE status = 'Active' OR 'Pending' B
WHERE status IN ('Active', 'Pending') C
WHERE status = ('Active', 'Pending') D
WHERE status BETWEEN 'Active' AND 'Pending'
Analysis & Theory
IN allows you to specify multiple possible values.
Which query selects products with a price between 100 and 500 inclusive?
A
WHERE price >= 100 OR price <= 500 B
WHERE price BETWEEN 100 TO 500 C
WHERE price BETWEEN 100 AND 500 D
WHERE price IN (100 AND 500)
Analysis & Theory
BETWEEN ... AND ... checks for a range, including the boundary values.
Which clause is used to filter rows before grouping?
A
HAVING B
ORDER BY C
WHERE D
GROUP BY
Analysis & Theory
WHERE filters rows before grouping or aggregation.
How do you select customers whose name starts with 'A'?
A
WHERE name LIKE 'A%' B
WHERE name = 'A*' C
WHERE name STARTS WITH 'A' D
WHERE name LIKE '^A'
Analysis & Theory
LIKE with 'A%' matches any string starting with 'A'.
What does the following query do? SELECT * FROM orders WHERE quantity <> 10;
A
Selects rows where quantity equals 10 B
Selects rows where quantity is not 10 C
Selects rows where quantity is NULL D
Returns an error
Analysis & Theory
<> means 'not equal to'.
How do you filter rows with date after '2023-01-01'?
A
WHERE date > '2023-01-01' B
WHERE date AFTER '2023-01-01' C
WHERE date >= '2023-01-01' D
WHERE date SINCE '2023-01-01'
Analysis & Theory
Use > to filter dates after the given value.