← All courses

A SQL paid-order report with NULL and date checks

SQL Analyst Starter

Write and run SQL queries to answer everyday business questions.

beginner · About 95 minutes · 4 lessons · 8 exercises + 1 project

Start lesson →

Your finished work

A SQL paid-order report with NULL and date checks

Completion requires every output check to pass. Exact columns, types, values, missing values and duplicate counts all matter. A diagnostic score helps you revise your work.

All examples use original, fictional business data. Your final project starts with 84 source records.

The course

  1. 1. Filter with both conditions

    Select paid orders strictly above a threshold.

    Start lesson →
  2. 2. Group without losing rows

    Aggregate revenue by a declared grouping key.

    Start lesson →
  3. 3. Join and keep unmatched orders

    Use a left join for a complete order list.

    Start lesson →
  4. 4. Treat NULL explicitly

    Distinguish missing values from zero and blank text.

    Start lesson →

Put it together

Build a checked paid-order report

84 source records. Apply the business rules, check your output and download a handoff report with your source, answer and results.

Preview your first input

CREATE TABLE orders(order_id INTEGER, customer_id INTEGER, status TEXT, amount INTEGER, region TEXT, ordered_at TEXT);
INSERT INTO orders VALUES (1,1,'paid',120,'East','2026-09-01'),(2,2,'pending',140,'West','2026-09-02'),(3,1,'paid',100,'East','2026-09-03'),(4,3,'paid',180,'West','2026-09-03'),(5,99,'paid',80,'East','2026-09-04'),(6,NULL,'cancelled',0,NULL,'2026-09-04'),(7,2,'paid',120,'West','2026-09-05'),(8,4,'paid',30,'North','2026-09-06');
CREATE TABLE customers(customer_id INTEGER PRIMARY KEY,name TEXT,email TEXT);
INSERT INTO customers VALUES(1,'Avery','team@example.test'),(2,'Morgan','team@example.test'),(3,'Riley',NULL),(4,'Casey',''),(5,'Sky','sky@example.test');
CREATE TABLE returns(return_id INTEGER,order_id INTEGER,refund INTEGER);
INSERT INTO returns VALUES(1,1,20),(2,1,10),(3,4,180),(4,99,25);
CREATE TABLE inventory(sku TEXT,on_hand INTEGER,reorder_at INTEGER);
INSERT INTO inventory VALUES('PEN',5,10),('BOOK',20,10),('MUG',0,5),('BAG',NULL,4),('CARD',4,4);
CREATE TABLE events(event_id INTEGER,customer_id INTEGER,stage TEXT);
INSERT INTO events VALUES(1,1,'visit'),(2,1,'visit'),(3,1,'checkout'),(4,2,'visit'),(5,3,'visit'),(6,3,'checkout'),(7,4,'visit');