Your question is SQL for Three Questions. Start with the requirements and the four tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
RealSelf wants a recurring provider performance report covering qualified leads generated through its marketplace and the appointments associated with those leads.
Write PostgreSQL queries to answer the following three questions for January through March 2025. Combine the outputs into one result set with a report_section column so each analysis can be identified.
| Column | Type | Description |
|---|---|---|
| provider_idPK | INT | Unique RealSelf provider identifier |
| provider_name | VARCHAR(100) | Provider display name |
| specialty | VARCHAR(100) | Primary medical specialty |
| Column | Type | Description |
|---|---|---|
| procedure_idPK | INT | Unique procedure identifier |
| procedure_name | VARCHAR(120) | RealSelf procedure name |
| category | VARCHAR(60) | Procedure category |
| Column | Type | Description |
|---|---|---|
| lead_idPK | INT | Unique inquiry or lead identifier |
| provider_id | INT | Referenced RealSelf provider |
| procedure_id | INT | Procedure associated with the inquiry |
| created_at | TIMESTAMP | Lead creation timestamp |
| status | VARCHAR(30) | Lead lifecycle status |
| source | VARCHAR(40) | Lead acquisition source |
| Column | Type | Description |
|---|---|---|
| appointment_idPK | INT | Unique appointment identifier |
| lead_id | INT | Lead that produced the appointment |
| appointment_date | DATE | Scheduled appointment date |
| status | VARCHAR(25) | Appointment outcome |
| revenue | DECIMAL(10,2) | Attributed revenue when available |