Unity Technologies BI analysts need to monitor annual revenue across Unity products such as Unity Ads, Unity Cloud, and the Unity Asset Store. Write a PostgreSQL query that joins product metadata with revenue records and calculates year-over-year performance.
Requirements
- Include revenue from 2023 through 2025 and aggregate it by product and calendar year.
- Use a window function to show the previous available year's revenue for each product.
- Calculate percentage growth only when the immediately preceding calendar year exists and its revenue is nonzero. Return
NULL otherwise.
- Return results ordered by product name and revenue year.
Output details
- Return columns in this order:
product_id, product_name, revenue_year, revenue, previous_year_revenue, yoy_growth_pct.
- Sort by
product_name ascending, then revenue_year ascending.
- Round
yoy_growth_pct to exactly two decimal places.
- Return
previous_year_revenue as NULL when no earlier revenue row exists.
- Include dates on or after
DATE '2023-01-01' and before DATE '2026-01-01'.