AnalystPath

Solar Installer Monthly Activity (2021)

SQLHardSenior level~15 min

Problem

A solar company onboards installers and fields install requests; an accepted request becomes a booking.

`Installers`: `installer_id` (int), `onboarded_on` (date) — when the installer joined.
`Requests`: `request_id` (int), `household_id` (int), `requested_on` (date).
`Bookings`: `request_id` (int), `installer_id` (int), `panel_count` (int), `job_minutes` (int) — one row per accepted request.

For **each month of 2021** (1 through 12), report:
- `active_installers` — installers onboarded on or before the end of that month (an installer onboarded in Dec 2020 counts in every 2021 month),
- `booked_requests` — bookings whose request was made in that month of 2021.

Every month 1..12 must appear even if it has zero bookings. Rows may be in any order.

Tables

Example rows — the live problem includes the full dataset.

Installers
installer_idonboarded_on
102020-12-10
82021-01-13
52021-02-16
Requests
request_idhousehold_idrequested_on
6752020-12-09
1542021-02-09
10632021-03-04
Bookings
request_idinstaller_idpanel_countjob_minutes
10106338
13107396
7810028

Expected output

Your answer should return 12 rows with the columns month, active_installers, booked_requests.

Starter code (SQL)

SELECT *
FROM Installers;

Solve this SQL question free

Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.

Solution & explanation

Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.

Sign up free to unlock

Related SQL questions