Challenge: Calculate Percentage Growth
Uppgift
Swipe to start coding
Write a SQL query to calculate the percentage growth in revenue for each month compared to the previous month.
- Group the
revenuetable by month and sum theamountfor each month. - Use a window function to access the previous month's total revenue for each row.
- Calculate the percentage growth as the difference between the current and previous month's revenue divided by the previous month's revenue, multiplied by 100.
- Handle cases where the previous month's revenue is
NULLor zero by returningNULLfor the percentage growth.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 2. Kapitel 6
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Fantastiskt!
Completion betyg förbättrat till 4.55
Challenge: Calculate Percentage Growth
Svep för att visa menyn
Uppgift
Swipe to start coding
Write a SQL query to calculate the percentage growth in revenue for each month compared to the previous month.
- Group the
revenuetable by month and sum theamountfor each month. - Use a window function to access the previous month's total revenue for each row.
- Calculate the percentage growth as the difference between the current and previous month's revenue divided by the previous month's revenue, multiplied by 100.
- Handle cases where the previous month's revenue is
NULLor zero by returningNULLfor the percentage growth.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 2. Kapitel 6
single