MENU

Fun & Interesting

How to Calculate year-on-year (YoY) Growth in Sales Amount for each year?| SQL Interview Preparation

Nishtha Nagar 557 lượt xem 1 month ago
Video Not Working? Fix It Now

Learn how to calculate Year-on-Year (YoY) growth in sales using SQL with a simple example. This is a common question in SQL interviews, especially for data analyst or data engineer roles. We’ll walk through the logic step-by-step using a sales dataset.


Script -

-- Create the table
CREATE TABLE sales (
year INT PRIMARY KEY,
total_sales INT
);

-- Insert the data
INSERT INTO sales (year, total_sales) VALUES
(2020, 50000),
(2021, 60000),
(2022, 75000),
(2023, 90000);

#sql #dataanalysts #dataengineer #dataanalysis #interviewquestion #sqlinterview #sqlinterviewquestions #education #dataanalytics

Comment