About this problem
The business question
The VP of Sales is preparing Q1 2024 performance reviews and needs one line per rep. Reps who closed nothing must still appear on the report with zero, because those are exactly the conversations the VP needs to have.
Expected result: One row per sales rep with rep_name, region, and Q1 2024 closed-won revenue, showing 0 for reps with no qualifying deals.
What you will practice
Tables
CREATE TABLE sales_reps (
rep_id INT PRIMARY KEY,
rep_name VARCHAR(80) NOT NULL,
region VARCHAR(30) NOT NULL
);
CREATE TABLE deals (
deal_id INT PRIMARY KEY,
rep_id INT NOT NULL REFERENCES sales_reps(rep_id),
stage VARCHAR(20) NOT NULL,
amount NUMERIC(12, 2) NOT NULL,
closed_at DATE
);More Joins practice
20 problems in this topic, with key concepts and common mistakes.