SELECT Queries & Filtering — Concept Check
Questions on SELECT Queries & Filtering. SELECT with WHERE, LIKE, BETWEEN, IN, IS NULL, and REGEXP filters rows; column aliases, DISTINCT, and case-insensitive string comparison (COLLATION) are foundational query skills.
Questions in this quiz
8 questions on SELECT Queries & Filtering — Concept Check. Work through them here, then start the quiz to answer them and see your score.
1.A query is returning rows with duplicate values in a column. Which SQL clause can help remove these duplicates?
- AGROUP BY
- BLIMIT
- CDISTINCT
- DORDER BY
2.You have a table with a column 'status' that can be NULL. Which condition correctly filters rows where 'status' is not NULL?
- AWHERE status != NULL
- BWHERE status IS NOT NULL OR status = ''
- CWHERE status IS NOT NULL
- DWHERE status <> NULL
3.A query using LIKE '%@gmail.com' is slow. What might improve its performance?
- AUse REGEXP instead of LIKE
- BChange to LIKE '@gmail.com%'
- CRemove the wildcard from LIKE
- DAdd an index on the email column
4.Which of the following queries will correctly select products priced between 100 and 200 inclusive?
- ASELECT * FROM products WHERE price BETWEEN 100 AND 200
- BSELECT * FROM products WHERE price > 100 AND price < 200
- CSELECT * FROM products WHERE price >= 100 OR price <= 200
- DSELECT * FROM products WHERE price BETWEEN 100 AND 200 EXCLUSIVE
5.A query uses WHERE customer_id IN (SELECT id FROM customers WHERE tier = 'GOLD'). What does this subquery do?
- AFilters customers with NULL tier
- BSelects orders with any customer_id
- CFilters orders for customers in the 'GOLD' tier
- DSelects all customers in any tier
6.A query with WHERE clause is not using an index. What could be a reason?
- AThe column is a primary key
- BThe column has a unique constraint
- CThe WHERE clause uses a subquery
- DThe column is not indexed
7.In a SELECT query, why can't you use a column alias in the WHERE clause?
- AAliases are only for ORDER BY
- BAliases are evaluated after WHERE
- CAliases are for computed columns only
- DAliases are not allowed in SQL
8.A query uses ORDER BY category ASC, price DESC. What does this achieve?
- ASorts by price descending, then category ascending
- BSorts by category descending, then price ascending
- CSorts by category ascending, then price descending
- DSorts by price ascending, then category descending