In this video, we solve one of the most frequently asked SQL interview questions:
👉 Find employees whose salary is increasing every year.
This question is commonly asked in SQL interviews for Data Analyst, Data Engineer, and Backend roles at companies like Amazon, Microsoft, Accenture, Deloitte, and more.
We use:
✔ SQL Window Functions
✔ LAG() analytical function
✔ CTE (Common Table Expression)
✔ HAVING clause with aggregation logic
You’ll learn:
How to compare salary year over year
Why LAG() is used in SQL interviews
How HAVING MIN() logic filters valid employees
Multiple alternate approaches to solve the same problem
This video is perfect for:
SQL interview preparation
Advanced SQL practice
Data Analyst & Data Engineer interviews
Window function mastery
If you want more real SQL interview questions with clean explanations, don’t forget to LIKE, SHARE, and SUBSCRIBE 🚀
.
.
.
.
#SQLInterviewQuestion
#SQLWindowFunctions
#LAGFunction
#CTE
#SQLForDataAnalyst
#SQLForDataEngineer
#AdvancedSQL
#SQLPractice
#SQLInterviewPreparation
#DataAnalytics
**********************************************************************
CREATE TABLE #employee_salary_history (
emp_id INT,
emp_name VARCHAR(50),
year INT,
salary INT
);
INSERT INTO #employee_salary_history (emp_id, emp_name, year, salary) VALUES
(101, 'Aarav', 2020, 600000),
(101, 'Aarav', 2021, 680000),
(101, 'Aarav', 2022, 750000),
(101, 'Aarav', 2023, 840000),
(102, 'Priya', 2020, 720000),
(102, 'Priya', 2021, 720000),
(102, 'Priya', 2022, 780000),
(103, 'Rahul', 2020, 550000),
(103, 'Rahul', 2021, 590000),
(103, 'Rahul', 2022, 570000),
(104, 'Sneha', 2020, 630000),
(104, 'Sneha', 2021, 690000),
(104, 'Sneha', 2022, 760000),
(104, 'Sneha', 2023, 820000);
Информация по комментариям в разработке