Challenge: Year-over-Year Revenue Comparison
Завдання
Swipe to start coding
Your task is to calculate the year-over-year (YoY) revenue growth percentage for each month using the revenue table.
- Group the revenue data by year and month.
- Use a window function such as
LAG()to get the previous year's revenue for the same month. - Calculate the YoY growth percentage using the formula:
(current_year_revenue - last_year_revenue) / last_year_revenue * 100. - Your query should return the following columns:
year: the year of the revenue period.month: the month of the revenue period.total_revenue: total revenue for that year and month.last_year_revenue: total revenue for the same month in the previous year.yoy_growth_percent: the YoY growth percentage, as a numeric value (can be decimal).
- Only include rows where
last_year_revenueis not null (i.e., exclude the first year for each month).
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 4
single
Запитати АІ
Запитати АІ
Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Чудово!
Completion показник покращився до 4.55
Challenge: Year-over-Year Revenue Comparison
Свайпніть щоб показати меню
Завдання
Swipe to start coding
Your task is to calculate the year-over-year (YoY) revenue growth percentage for each month using the revenue table.
- Group the revenue data by year and month.
- Use a window function such as
LAG()to get the previous year's revenue for the same month. - Calculate the YoY growth percentage using the formula:
(current_year_revenue - last_year_revenue) / last_year_revenue * 100. - Your query should return the following columns:
year: the year of the revenue period.month: the month of the revenue period.total_revenue: total revenue for that year and month.last_year_revenue: total revenue for the same month in the previous year.yoy_growth_percent: the YoY growth percentage, as a numeric value (can be decimal).
- Only include rows where
last_year_revenueis not null (i.e., exclude the first year for each month).
Рішення
Все було зрозуміло?
Дякуємо за ваш відгук!
Секція 2. Розділ 4
single