Challenge: Calculate Percentage Growth
Tarea
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.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 6
single
Pregunte a AI
Pregunte a AI
Pregunte lo que quiera o pruebe una de las preguntas sugeridas para comenzar nuestra charla
Suggested prompts:
Can you explain this in simpler terms?
What are the main points I should remember?
Can you give me an example?
Genial!
Completion tasa mejorada a 4.55
Challenge: Calculate Percentage Growth
Desliza para mostrar el menú
Tarea
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.
Solución
¿Todo estuvo claro?
¡Gracias por tus comentarios!
Sección 2. Capítulo 6
single