Departmental Spend By Quarter
Start Timer
0:00:00
Suppose we have a table of transactions happened during 2023, with each transaction belonging to different departments within a company. We want to calculate the total spend for IT
, HR
, and Marketing
, and also have a total for Other
departments, grouped by fiscal quarters.
Write a query to display this result.
Note: Display only quarters where at least one transaction occurred. Quarter names should be Q1,Q2,Q3 and Q4. Q1 is from January to March
Example:
Input:
transactions
table
Column | Type |
---|---|
transaction_id |
INTEGER |
department |
VARCHAR |
amount |
FLOAT |
transaction_date |
DATE |
Output:
Column | Type |
---|---|
quarter |
VARCHAR |
it_spending |
FLOAT |
hr_spending |
FLOAT |
marketing_spending |
FLOAT |
other_spending |
FLOAT |
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments