Beginner level · Module 2 of 5 · 11 guided hours
Filtering and Sorting with SQL
Select exactly the rows you need with WHERE, combine conditions, handle missing values and sort and limit results.
Learning objectives
- Filter rows with comparison and logical operators
- Use LIKE, IN, BETWEEN and handle NULL correctly
- Sort, limit and calculate values in results
Topics
- WHERE with =, <>, <, >
- AND, OR, NOT and parentheses
- LIKE, IN and BETWEEN
- NULL and IS NULL
- ORDER BY, LIMIT and DISTINCT
- calculated columns and aliases
Lessons
-
Lesson 1 Filtering Rows with WHERE
Select rows that meet conditions, combining them with AND, OR and NOT.
WHEREcomparison operatorsAND / OR / NOToperator precedence
-
Lesson 2 Patterns, Lists, Ranges and NULL
Match text patterns with LIKE, test lists with IN and ranges with BETWEEN, and handle missing values.
LIKE and %IN (…)BETWEENNULL, IS NULL, COALESCE
-
Lesson 3 Sorting, Limiting and Calculated Columns
Order results, take the top rows, remove duplicates and calculate new values with aliases.
ORDER BY ASC/DESCLIMITDISTINCTexpressions and AS
Practical activity
Answer fifteen questions from a clinic visits table, such as visits last month for malaria, patients without a phone number and the ten most recent visits.
Expected outcomes
- Precise queries that answer real questions
- Correct handling of missing values
Assessment
Query test: ten questions answered with SQL; marked on correct results.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.