Tech Coach

SQL Challenge #DAY2: Calculate the Year-over-Year Sales Growth

Hey everyone!

Today, we're diving into a new SQL challenge. Given the dataset below, your task is to calculate the year-over-year (YoY) sales growth percentage for each employee. Use a window function to compare the sales of the current year with the previous year.

Sample Data:

Sale_ID Sale_Date Employee_ID Amount ($)
1 2023-09-01 101 1500
2 2023-09-01 102 1700
3 2024-09-01 101 1600
4 2024-09-02 103 1800
5 2024-09-02 101 1400
6 2024-09-02 102 1900
7 2023-09-03 103 1500
8 2023-09-03 101 1600
9 2024-09-03 102 2000
10 2024-09-14 103 2100

Your task:
Write a SQL query to calculate the year-over-year sales growth for each employee using window functions. How much did their sales grow or decline compared to the same period in the previous year?

11 months ago | [YT] | 2