SQL interview question: Compound Annual Growth Rate (CAGR)
Calculate CAGR (Compound Annual Growth Rate)
Investment analysts need to calculate the compound annual growth rate of revenue over multiple years.
Calculate CAGR using: ((Ending Value / Beginning Value) ^ (1 / Years)) - 1
Return start_year, end_year, and cagr_percent (rounded to 2 decimals). Use POWER() function.
Skills: POWER function and complex calculations
Tables
yearly_revenue 5 rows
- year integer PK
- revenue real
| year | revenue |
|---|---|
| 2020 | 1000000.0 |
| 2021 | 1200000.0 |
| 2022 | 1500000.0 |