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
| # | Problem | Platform | Difficulty | Open | 1st1st Visit | 2nd2nd Visit | RevRevise |
|---|---|---|---|---|---|---|---|
| 1 | Recyclable and Low Fat Products | LeetCode | Easy | Solve Recyclable and Low Fat Products on LeetCode (opens in a new tab) | |||
| 2 | Big Countries | LeetCode | Easy | Solve Big Countries on LeetCode (opens in a new tab) | |||
| 3 | Article Views I | LeetCode | Easy | Solve Article Views I on LeetCode (opens in a new tab) | |||
| 4 | Not Boring Movies | LeetCode | Easy | Solve Not Boring Movies on LeetCode (opens in a new tab) | |||
| 5 | Find Customer Referee | LeetCode | Easy | Solve Find Customer Referee on LeetCode (opens in a new tab) |