Hard AggregationSubqueries Premium

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
yearrevenue
20201000000.0
20211200000.0
20221500000.0

Keep going