Challenge: Calculate Percentage Growth
Task
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.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 6
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Awesome!
Completion rate improved to 4.55
Challenge: Calculate Percentage Growth
Swipe to show menu
Task
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.
Solution
Everything was clear?
Thanks for your feedback!
SectionΒ 2. ChapterΒ 6
single