SQL for business analysts: check requirements against real data
As a business analyst you rarely build the final report, but you need to know whether the data can support a requirement. A few queries let you check that yourself instead of waiting for an export. Here are five typical BA tasks, each with an example and an exercise.
In short: for business analysis, SELECT, WHERE, GROUP BY, CASE and JOIN usually cover it, which is levels 1 to 3 of the course. With them you see which values are really in a table, how many fields are empty, what a KPI comes to under each definition and which records are missing between two systems.
What business analysts use SQL for
| Task | Typical question | SQL for it | Lesson |
|---|---|---|---|
| Check a requirement | Does the field the business wants in the report exist? Which values does it hold? | DISTINCT, GROUP BY with COUNT | DISTINCT, GROUP BY |
| Profile the data | How many rows, how many empty fields, which date range? | COUNT(*), COUNT(column), MIN, MAX | COUNT, NULL |
| Define a KPI | What exactly counts as revenue, an active customer, a cancellation? | SUM with CASE WHEN | CASE WHEN, aggregate functions |
| Reconcile systems | Which customers in the CRM are missing from accounting? | LEFT JOIN with IS NULL, NOT EXISTS | LEFT JOIN, EXISTS |
| Measure data quality | Are customers duplicated? Are required fields missing? | GROUP BY with HAVING COUNT(*) > 1 | find duplicates, HAVING |
Example 1: look at the data before you ask questions
Before you write a requirement, a quick profile of the table pays off. One query shows how many rows there are, whether the key is unique, how often a field is filled in and which period the data covers. The example uses the customers table of the practice database, an online office supplies shop:
SELECT COUNT(*) AS row_count,
COUNT(DISTINCT customer_id) AS customer_ids,
COUNT(phone) AS with_phone,
COUNT(DISTINCT city) AS cities,
MIN(customer_since) AS earliest,
MAX(customer_since) AS latest
FROM customers;
| row_count | customer_ids | with_phone | cities | earliest | latest |
|---|---|---|---|---|---|
| 12 | 12 | 9 | 9 | 2020-06-12 | 2025-05-30 |
What it tells you: every customer ID appears once. Three of twelve customers have no phone number, because COUNT(phone) only counts filled-in fields. If sales asks for a call list of all customers, that is a question for the spec: what happens to the three without a number? Finding gaps like this early saves a round trip with the developers later.
Example 2: which values really exist?
Requirements often say "all completed orders". A grouping shows which statuses are actually in the data:
SELECT status, COUNT(*) AS orders
FROM orders
GROUP BY status
ORDER BY orders DESC, status;
| status | orders |
|---|---|
| delivered | 11 |
| open | 3 |
| cancelled | 2 |
| shipped | 2 |
Four statuses, and "completed" is not one of them. Whether "shipped" counts is for the business to decide, not the query. Write the answer into the requirement as a list of values, and there won't be two readings later.
Example 3: one KPI, three numbers
"Revenue" sounds clear. With CASE WHEN inside the sum you can put three common definitions side by side in one query:
SELECT ROUND(SUM(i.quantity * i.unit_price), 2) AS all_orders,
ROUND(SUM(CASE WHEN o.status <> 'cancelled'
THEN i.quantity * i.unit_price END), 2) AS excl_cancelled,
ROUND(SUM(CASE WHEN o.status = 'delivered'
THEN i.quantity * i.unit_price END), 2) AS delivered_only
FROM orders AS o
JOIN order_items AS i ON i.order_id = o.order_id;
| all_orders | excl_cancelled | delivered_only |
|---|---|---|
| 9782.11 | 9054.11 | 6720.2 |
The largest and the smallest number are just over 3,000 apart, almost a third. If the spec only says "revenue", you get one of these three numbers depending on who builds the query. A good KPI definition therefore names the table, the filter and the calculation. Practise it on the headline numbers for a year:
Task Management wants the headline numbers for the year in a single row. Include every order that isn't cancelled and show: orders (count), revenue (sum of amount, rounded to 2 decimals), avg_order_value (average amount per order, rounded to 2 decimals) and customers (number of different customers who ordered).
orders 122 rows, 5 columns
| order_id | customer_id | order_date | status | amount |
|---|---|---|---|---|
| 5001 | 2 | 2025-11-01 | cancelled | 93.9 |
| 5002 | 4 | 2025-11-02 | delivered | 238.8 |
| 5003 | 6 | 2025-11-08 | delivered | 14.9 |
| 5004 | 3 | 2025-11-10 | delivered | 29.9 |
| 5005 | 7 | 2025-11-11 | delivered | 44.9 |
| 5006 | 5 | 2025-11-13 | delivered | 104.7 |
| 5007 | 11 | 2025-11-16 | delivered | 17.9 |
| 5008 | 13 | 2025-11-17 | delivered | 119 |
| 5009 | 9 | 2025-11-18 | delivered | 206.8 |
| 5010 | 10 | 2025-11-20 | delivered | 758 |
| 5011 | 12 | 2025-11-23 | delivered | 44.9 |
| 5012 | 1 | 2025-11-25 | delivered | 77.8 |
| 5013 | 4 | 2025-11-27 | delivered | 149 |
| 5014 | 8 | 2025-11-28 | delivered | 39.9 |
| 5015 | 10 | 2025-12-15 | delivered | 777.9 |
| 5016 | 14 | 2025-12-16 | delivered | 55.8 |
| 5017 | 2 | 2025-12-22 | delivered | 34.9 |
| 5018 | 16 | 2025-12-22 | delivered | 79 |
| 5019 | 15 | 2025-12-29 | delivered | 22.9 |
| 5020 | 20 | 2025-12-29 | delivered | 59.8 |
| 5021 | 21 | 2025-12-30 | delivered | 379 |
| 5022 | 19 | 2025-12-31 | delivered | 114.7 |
| 5023 | 17 | 2026-01-03 | delivered | 49.8 |
| 5024 | 18 | 2026-01-08 | delivered | 79 |
| 5025 | 6 | 2026-01-14 | delivered | 44.9 |
| 5026 | 11 | 2026-01-16 | delivered | 12.9 |
| 5027 | 9 | 2026-01-17 | delivered | 49.9 |
| 5028 | 2 | 2026-01-21 | delivered | 59.9 |
| 5029 | 22 | 2026-01-24 | delivered | 49.9 |
| 5030 | 24 | 2026-01-25 | delivered | 498 |
| 5031 | 25 | 2026-02-04 | delivered | 413.9 |
| 5032 | 5 | 2026-02-05 | delivered | 34.9 |
| 5033 | 28 | 2026-02-06 | cancelled | 34.9 |
| 5034 | 26 | 2026-02-11 | delivered | 17.9 |
| 5035 | 11 | 2026-02-20 | delivered | 39.9 |
| 5036 | 21 | 2026-02-23 | delivered | 170.9 |
| 5037 | 29 | 2026-02-25 | delivered | 49.9 |
| 5038 | 27 | 2026-02-26 | delivered | 24.9 |
| 5039 | 12 | 2026-03-03 | delivered | 308 |
| 5040 | 18 | 2026-03-03 | delivered | 26.9 |
| 5041 | 15 | 2026-03-06 | delivered | 99.6 |
| 5042 | 1 | 2026-03-07 | delivered | 403.8 |
| 5043 | 31 | 2026-03-11 | delivered | 417.7 |
| 5044 | 30 | 2026-03-12 | delivered | 149 |
| 5045 | 33 | 2026-03-13 | delivered | 158 |
| 5046 | 34 | 2026-03-19 | delivered | 189 |
| 5047 | 32 | 2026-03-27 | delivered | 123.8 |
| 5048 | 35 | 2026-03-30 | delivered | 93.9 |
| 5049 | 19 | 2026-04-01 | delivered | 69.8 |
| 5050 | 2 | 2026-04-04 | cancelled | 368.9 |
| 5051 | 34 | 2026-04-06 | delivered | 47.8 |
| 5052 | 20 | 2026-04-16 | delivered | 119 |
| 5053 | 6 | 2026-04-22 | delivered | 258.7 |
| 5054 | 2 | 2026-04-23 | cancelled | 126.7 |
| 5055 | 11 | 2026-04-24 | delivered | 29.9 |
| 5056 | 36 | 2026-04-26 | delivered | 79 |
| 5057 | 37 | 2026-04-26 | cancelled | 12.9 |
| 5058 | 39 | 2026-04-27 | delivered | 117.7 |
| 5059 | 38 | 2026-04-29 | delivered | 19.9 |
| 5060 | 22 | 2026-04-30 | delivered | 59.9 |
| 5061 | 99 | 2026-05-01 | delivered | 63.7 |
| 5062 | 40 | 2026-05-04 | delivered | 158 |
| 5063 | 41 | 2026-05-05 | delivered | 378 |
| 5064 | 29 | 2026-05-14 | delivered | 228.7 |
| 5065 | 43 | 2026-05-17 | delivered | 74.7 |
| 5066 | 45 | 2026-05-25 | cancelled | 39.9 |
| 5067 | 44 | 2026-05-27 | delivered | 69.8 |
| 5068 | 46 | 2026-05-31 | delivered | 80.7 |
| 5069 | 27 | 2026-06-04 | delivered | 97.7 |
| 5070 | 31 | 2026-06-09 | delivered | 68.7 |
| 5071 | 18 | 2026-06-10 | delivered | 189 |
| 5072 | 19 | 2026-06-11 | delivered | 57.7 |
| 5073 | 35 | 2026-06-13 | delivered | 149 |
| 5074 | 47 | 2026-06-19 | delivered | 119 |
| 5075 | 49 | 2026-06-20 | delivered | 39.9 |
| 5076 | 48 | 2026-06-23 | delivered | 49.9 |
| 5077 | 42 | 2026-06-25 | delivered | 19.9 |
| 5078 | 51 | 2026-06-27 | delivered | 34.9 |
| 5079 | 39 | 2026-07-01 | delivered | 59.7 |
| 5080 | 50 | 2026-07-01 | delivered | 25.8 |
| 5081 | 45 | 2026-07-02 | delivered | 188.8 |
| 5082 | 19 | 2026-07-04 | delivered | 134.4 |
| 5083 | 53 | 2026-07-12 | delivered | 83.7 |
| 5084 | 52 | 2026-07-14 | delivered | 77.8 |
| 5085 | 38 | 2026-07-15 | delivered | 129.7 |
| 5086 | 54 | 2026-07-15 | delivered | 418.8 |
| 5087 | 46 | 2026-07-17 | delivered | 59.8 |
| 5088 | 29 | 2026-07-19 | delivered | 188.9 |
| 5089 | 36 | 2026-07-19 | delivered | 124.7 |
| 5090 | 45 | 2026-07-27 | delivered | 14.9 |
| 5091 | 41 | 2026-07-29 | delivered | 19.9 |
| 5092 | 58 | 2026-08-01 | delivered | 99.8 |
| 5093 | 56 | 2026-08-05 | delivered | 74.7 |
| 5094 | 53 | 2026-08-06 | delivered | 98.9 |
| 5095 | 59 | 2026-08-07 | delivered | 22.9 |
| 5096 | 18 | 2026-08-12 | delivered | 1157 |
| 5097 | 61 | 2026-08-16 | delivered | 44.7 |
| 5098 | 29 | 2026-08-20 | delivered | 105.7 |
| 5099 | 60 | 2026-08-24 | delivered | 307 |
| 5100 | 39 | 2026-08-27 | delivered | 103.9 |
| 5101 | 44 | 2026-08-28 | delivered | 243.8 |
| 5102 | 31 | 2026-08-31 | delivered | 128.9 |
| 5103 | 54 | 2026-08-31 | delivered | 298 |
| 5104 | 42 | 2026-09-01 | delivered | 388.9 |
| 5105 | 47 | 2026-09-01 | delivered | 124.7 |
| 5106 | 63 | 2026-09-06 | cancelled | 14.9 |
| 5107 | 64 | 2026-09-06 | delivered | 62.8 |
| 5108 | 65 | 2026-09-06 | cancelled | 208.6 |
| 5109 | 62 | 2026-09-11 | delivered | 34.9 |
| 5110 | 27 | 2026-09-18 | delivered | 29.9 |
| 5111 | 42 | 2026-09-20 | delivered | 104.7 |
| 5112 | 41 | 2026-09-21 | delivered | 24.9 |
| 5113 | 46 | 2026-09-27 | delivered | 94.6 |
| 5114 | 66 | 2026-09-28 | delivered | 29.9 |
| 5115 | 67 | 2026-10-01 | delivered | 34.9 |
| 5116 | 51 | 2026-10-07 | delivered | 69.8 |
| 5117 | 53 | 2026-10-07 | cancelled | 34.9 |
| 5118 | 70 | 2026-10-09 | delivered | 211.9 |
| 5119 | 64 | 2026-10-16 | delivered | 698 |
| 5120 | 68 | 2026-10-21 | delivered | 183.9 |
| 5121 | 69 | 2026-10-27 | shipped | 159.4 |
| 5122 | 27 | 2026-10-30 | shipped | 118.9 |
Example 4: reconcile two systems
A common project task: which records exist in one system but not in the other? Customers with no orders, orders with no invoice, employees with no cost center. The pattern is always the same: a LEFT JOIN that keeps every row of the first table, and a filter on the rows where nothing was found on the right:
SELECT c.customer_id, c.name
FROM customers AS c
LEFT JOIN orders AS o ON o.customer_id = c.customer_id
WHERE o.order_id IS NULL;
In the practice database every customer has ordered at least once, so the result is empty. That is an answer too, and it belongs in the spec. When the data lives in two separate systems, it usually ends up in a shared database or a data warehouse first. Then the key question is which key you join on, for example the customer number from the CRM and the account number from accounting. In the exercise two new customers without orders have been added, and the list should show every customer:
Task Two new customers have signed up but haven't ordered anything yet. Management still wants every customer on the list: name from customers, plus order_id and order_date of each of their orders. Customers with no orders should appear with empty fields.
customers 14 rows, 7 columns
| customer_id | name | city | country | customer_since | segment | phone |
|---|---|---|---|---|---|---|
| 1 | Harbor Fremont Partners | Boston | USA | 2021-03-15 | Business | 617-555-0142 |
| 2 | Emily Carter | Chicago | USA | 2022-07-01 | Consumer | NULL |
| 3 | Riverside County Office | Riverside | USA | 2020-11-20 | Government | 951-555-0110 |
| 4 | Raj Patel | Leeds | UK | 2023-01-09 | Consumer | 0113 496 0123 |
| 5 | Lakeview Hotel Ltd | Manchester | UK | 2022-04-18 | Business | 0161 496 0456 |
| 6 | Olivia Brooks | Austin | USA | 2024-02-27 | Consumer | NULL |
| 7 | Greene & Shaw LLP | London | UK | 2021-09-05 | Business | 020 7946 0321 |
| 8 | Maple Grove High School | Austin | USA | 2023-08-14 | School | 512-555-0187 |
| 9 | Chloe Evans | Boston | USA | 2025-05-30 | Consumer | 617-555-0199 |
| 10 | Northline Printing Co | Toronto | Canada | 2020-06-12 | Business | 416-555-0133 |
| 11 | Daniel Kim | Seattle | USA | 2024-10-03 | Consumer | NULL |
| 12 | Westbrook Dental Clinic | Chicago | USA | 2022-12-01 | Business | 312-555-0164 |
| 15 | Harlow Street Bakery | Glasgow | UK | 2026-06-08 | Business | 0141 496 0574 |
| 16 | Jordan Ellis | Portland | USA | 2026-06-11 | Consumer | NULL |
orders 18 rows, 5 columns
| order_id | customer_id | order_date | status | employee_id |
|---|---|---|---|---|
| 1001 | 1 | 2026-01-08 | delivered | 3 |
| 1002 | 4 | 2026-01-12 | delivered | 4 |
| 1003 | 3 | 2026-01-20 | delivered | 3 |
| 1004 | 7 | 2026-02-03 | delivered | 4 |
| 1005 | 2 | 2026-02-11 | cancelled | 8 |
| 1006 | 1 | 2026-02-25 | delivered | 3 |
| 1007 | 10 | 2026-03-04 | delivered | 2 |
| 1008 | 5 | 2026-03-17 | delivered | 4 |
| 1009 | 8 | 2026-03-30 | delivered | 3 |
| 1010 | 6 | 2026-04-07 | delivered | 8 |
| 1011 | 12 | 2026-04-22 | delivered | 4 |
| 1012 | 3 | 2026-05-06 | delivered | 3 |
| 1013 | 9 | 2026-05-19 | cancelled | 8 |
| 1014 | 7 | 2026-06-02 | shipped | 4 |
| 1015 | 1 | 2026-06-10 | shipped | 3 |
| 1016 | 11 | 2026-06-12 | open | NULL |
| 1017 | 4 | 2026-06-13 | open | NULL |
| 1018 | 10 | 2026-06-14 | open | NULL |
Example 5: measure data quality instead of guessing
"The data is bad" doesn't help a project. "37 customers are duplicated, 12 percent have no email" does, because you can estimate the effort from it. You find duplicates with GROUP BY and HAVING COUNT(*) > 1. Often you have to standardize the values first, for example trim spaces and convert everything to lower case:
Task Before the analysis you check the customers table for duplicates. Two entries count as the same person if their email address is identical once leading and trailing spaces are removed and it is in lower case. Show email (in that cleaned form) and occurrences for every address that appears more than once.
customers 70 rows, 6 columns
| customer_id | name | city | signup_date | channel | |
|---|---|---|---|---|---|
| 1 | Samuel Ward | samuel.ward@example.com | Austin | 2025-10-07 | Newsletter |
| 2 | Owen Robinson | owen.robinson@example.com | Denver | 2025-08-02 | Referral |
| 3 | Liam Martin | liam.martin@example.com | Chicago | 2025-09-17 | Search |
| 4 | Thomas Hughes | thomas.hughes@example.com | Bristol | 2025-09-07 | Search |
| 5 | Chloe Lewis | chloe.lewis@example.com | Bristol | 2025-09-03 | Newsletter |
| 6 | Connor Hall | connor.hall@example.com | New York | 2025-07-07 | Referral |
| 7 | Lily Robinson | lily.robinson@example.com | Glasgow | 2025-07-31 | Newsletter |
| 8 | James Thomas | james.thomas@example.com | Glasgow | 2025-07-02 | Search |
| 9 | Aisha Green | aisha.green@example.com | Chicago | 2025-07-16 | Newsletter |
| 10 | Sophia Murphy | sophia.murphy@example.com | Birmingham | 2025-08-03 | Search |
| 11 | Emily Harris | emily.harris@example.com | Leeds | 2025-11-08 | Search |
| 12 | Hannah Thomas | hannah.thomas@example.com | NULL | 2025-11-16 | Search |
| 13 | Ethan Hall | ethan.hall@example.com | Austin | 2025-11-13 | Search |
| 14 | Lucas Price | lucas.price@example.com | Leeds | 2025-11-26 | Newsletter |
| 15 | Priya Harris | priya.harris@example.com | New York | 2025-12-05 | Newsletter |
| 16 | Lucas Reed | lucas.reed@example.com | Seattle | 2025-12-01 | Search |
| 17 | Fiona Campbell | fiona.campbell@example.com | Denver | 2025-12-11 | Search |
| 18 | Ryan Wright | ryan.wright@example.com | Chicago | 2025-12-14 | Social media |
| 19 | Priya Evans | priya.evans@example.com | Denver | 2025-12-26 | Search |
| 20 | Grace Campbell | grace.campbell@example.com | Denver | 2025-12-26 | Search |
| 21 | Aisha Price | aisha.price@example.com | New York | 2025-12-30 | Referral |
| 22 | Zoe Harris | zoe.harris@example.com | New York | 2026-01-11 | Newsletter |
| 23 | Liam Brown | liam.brown@example.com | Manchester | 2026-01-15 | Newsletter |
| 24 | Olivia Taylor | olivia.taylor@example.com | Denver | 2026-02-03 | Search |
| 25 | Aisha Wilson | aisha.wilson@example.com | Austin | 2026-02-13 | Search |
| 26 | Megan Reed | megan.reed@example.com | Glasgow | 2026-01-28 | Search |
| 27 | Amelia Green | NULL | Bristol | 2026-02-04 | Search |
| 28 | Kevin Wilson | kevin.wilson@example.com | Birmingham | 2026-02-06 | Search |
| 29 | Isla Morgan | isla.morgan@example.com | London | 2026-02-11 | Search |
| 30 | Liam Hall | liam.hall@example.com | Bristol | 2026-02-22 | Referral |
| 31 | Zoe Turner | zoe.turner@example.com | Birmingham | 2026-02-24 | Search |
| 32 | Daniel Evans | daniel.evans@example.com | Chicago | 2026-03-05 | Newsletter |
| 33 | Emily Wright | emily.wright@example.com | London | 2026-03-07 | Search |
| 34 | Connor Taylor | connor.taylor@example.com | Seattle | 2026-03-11 | Search |
| 35 | Olivia Reed | olivia.reed@example.com | New York | 2026-03-24 | Social media |
| 36 | Kevin Martin | kevin.martin@example.com | Birmingham | 2026-04-01 | Referral |
| 37 | Emily Davies | emily.davies@example.com | Austin | 2026-04-09 | Search |
| 38 | Ruby Johnson | ruby.johnson@example.com | NULL | 2026-04-08 | Social media |
| 39 | Henry Campbell | henry.campbell@example.com | Glasgow | 2026-04-10 | Newsletter |
| 40 | Ethan Murphy | ethan.murphy@example.com | Bristol | 2026-04-24 | Newsletter |
| 41 | Ethan Martin | ethan.martin@example.com | Manchester | 2026-05-01 | Referral |
| 42 | Liam Campbell | liam.campbell@example.com | Austin | 2026-04-30 | Search |
| 43 | Holly Harris | holly.harris@example.com | New York | 2026-05-10 | Search |
| 44 | Aaron Smith | aaron.smith@example.com | Manchester | 2026-05-13 | Newsletter |
| 45 | Aisha Baker | aisha.baker@example.com | Denver | 2026-05-19 | Social media |
| 46 | Isla Bennett | isla.bennett@example.com | Glasgow | 2026-05-18 | Social media |
| 47 | Chloe Davies | chloe.davies@example.com | Leeds | 2026-06-05 | Newsletter |
| 48 | Thomas Robinson | thomas.robinson@example.com | Boston | 2026-06-03 | Search |
| 49 | Marcus Evans | marcus.evans@example.com | Manchester | 2026-06-15 | Newsletter |
| 50 | Oliver Wright | oliver.wright@example.com | Bristol | 2026-06-10 | Search |
| 51 | Thomas Johnson | thomas.johnson@example.com | Glasgow | 2026-06-18 | Search |
| 52 | Sophia Reed | sophia.reed@example.com | London | 2026-06-24 | Search |
| 53 | Fiona Clarke | fiona.clarke@example.com | Leeds | 2026-07-02 | Referral |
| 54 | Liam Hall | LIAM.HALL@EXAMPLE.COM | Bristol | 2026-07-08 | Search |
| 55 | Lily Thomas | lily.thomas@example.com | Boston | 2026-07-14 | Search |
| 56 | Chloe Robinson | chloe.robinson@example.com | Bristol | 2026-07-26 | Search |
| 57 | Hannah Campbell | hannah.campbell@example.com | Boston | 2026-07-20 | Social media |
| 58 | Ruby Morgan | ruby.morgan@example.com | New York | 2026-07-29 | Search |
| 59 | Sophia Smith | sophia.smith@example.com | London | 2026-07-31 | Newsletter |
| 60 | Ava Martin | ava.martin@example.com | Birmingham | 2026-08-11 | Social media |
| 61 | Jack Hall | jack.hall@example.com | NULL | 2026-08-13 | Newsletter |
| 62 | Grace Cooper | grace.cooper@example.com | Chicago | 2026-08-25 | Search |
| 63 | Connor Price | connor.price@example.com | Manchester | 2026-08-23 | Search |
| 64 | Marcus Walker | marcus.walker@example.com | Bristol | 2026-09-04 | Social media |
| 65 | Holly Brown | holly.brown@example.com | Denver | 2026-09-06 | Search |
| 66 | Priya Evans | Priya.Evans@example.com | Denver | 2026-09-19 | Search |
| 67 | Carlos Garcia | carlos.garcia@example.com | Chicago | 2026-09-19 | Social media |
| 68 | Priya Thomas | priya.thomas@example.com | Bristol | 2026-09-29 | Search |
| 69 | Mia Reed | mia.reed@example.com | Chicago | 2026-10-02 | Search |
| 70 | Marcus Turner | marcus.turner@example.com | Boston | 2026-10-04 | Newsletter |
More checks, such as whether an order's amount matches the sum of its lines or whether orders point to customers that don't exist, are in the data quality case of the intensive course.
What business analysts don't need
Creating tables, granting permissions, tuning queries for speed: in most teams that is done by developers or database administrators. More important is reading SQL that others wrote, such as the query behind a report that suddenly shows different numbers. It helps to know the order in which the database runs a query: FROM and JOIN first, then WHERE, GROUP BY, HAVING, and SELECT and ORDER BY last.
Your path through the course
- Level 1, getting started (free): SELECT, WHERE, NULL, ORDER BY, DISTINCT. Enough to profile a table and check values.
- Level 2, summarizing: COUNT, SUM, GROUP BY, HAVING, CASE, dates. The core for KPIs.
- Level 3, joining tables: JOIN, LEFT JOIN, subqueries and EXISTS. This is how you reconcile tables.
- Level 5, if you want to show trends over time: CTEs, window functions, month-over-month comparisons. You don't need level 4 (changing data) for this.
After that, the SQL for data analysts intensive course continues with six cases: a KPI overview, an order funnel, ABC analysis, time series, cohorts and data quality, with its own certificate. More on the building blocks of analysis is on SQL for data analysis. If you come from Excel, SQL for Excel users shows the familiar ideas: VLOOKUP becomes JOIN, a PivotTable becomes GROUP BY. And for the Excel side of the job there is Excel for data analysis.
FAQ
Do business analysts need SQL?
Not every role asks for it; the job ad will tell you. If you know it, you can check requirements against the data yourself, spot gaps sooner and talk to developers on equal terms. For most tasks, levels 1 to 3 of the course are enough.
How does SQL differ for a business analyst and a data analyst?
The commands are the same, the purpose is different. A data analyst builds analyses and reports, often with window functions and long queries. A business analyst uses SQL more to check requirements, understand the data and pin down KPIs. For data analysts there is SQL for data analysis.
Which database should I learn?
The one your company uses, if you know it. Otherwise learn the basics, which are almost the same in MySQL, PostgreSQL, SQL Server and SQLite. Our exercises run on SQLite, and you can switch the model answer to MySQL, PostgreSQL or SQL Server.
Do I need to install anything?
No. All exercises run in your browser against a real database on the server. The results on this page come from exactly that database.
Can I prove my SQL skills?
Yes. After the course's final test you get an SQL certificate with a verification link, and the intensive course has its own data analysis certificate.