Your question is SQL Month-Over-Month Revenue and Gross Profit. Start with the requirements and the two 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.
Advance Business Capital's Operations team needs a monthly store performance view. Write a PostgreSQL query that calculates revenue, gross profit, and month-over-month changes for each store using qualifying transactions from January through March 2024.
store_transactions includes multiple transactions per store-month, a zero-revenue month, a NULL cost, an unmatched store, and a transaction outside the reporting period.
| Column | Type | Description |
|---|---|---|
| store_idPK | INTEGER | Unique store identifier |
| store_name | VARCHAR(100) | Store display name |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INTEGER | Unique transaction identifier |
| store_id | INTEGER | Referenced store identifier |
| transaction_date | DATE | Date the transaction occurred |
| revenue | NUMERIC(12,2) | Revenue generated by the transaction |
| cost | NUMERIC(12,2) | Transaction cost |