Skip to content
We areTOP 1%
DBMS & SQL · Beginner · Topic 4 of 5

SQL: SELECT & Filtering

5 questions.
Your progress0%
1st Visit
0/5
2nd Visit
0/5
Revise
0/5

Overview

Most SQL questions start by choosing rows and columns from one table. SELECT lists the output columns, FROM names the table and WHERE keeps only the rows whose condition is true. Conditions combine comparisons with AND, OR, NOT, IN, BETWEEN and LIKE; DISTINCT removes duplicate rows, and ORDER BY with LIMIT controls the order and number of rows returned. The classic trap is NULL: a comparison such as x <> 2 is unknown, not true, when x is NULL, so such rows disappear unless you add IS NULL. Although written first, SELECT is evaluated after FROM and WHERE, which is why a column alias cannot be used in WHERE.

SELECT DISTINCT city
FROM customers
WHERE age BETWEEN 18 AND 25
  AND (email LIKE '%@gmail.com' OR phone IS NULL)
ORDER BY city
LIMIT 10;

Questions

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account