American Express Interview | SQL Interview Question: Calculate Salary Difference Between Departments

  Рет қаралды 199

The Data -Tech Club

The Data -Tech Club

Күн бұрын

Пікірлер: 4
@aravindareddy7267
@aravindareddy7267 2 ай бұрын
Can we use max(salary) over (partition by department_id)
@Thedata.techclub
@Thedata.techclub 2 ай бұрын
Yes, it will work.
@HARSHRAJ-gp6ve
@HARSHRAJ-gp6ve 2 ай бұрын
with cte as( select salary,department FROM db_employee JOIN db_dept ON db_employee.department_id=db_dept.id ),cte1 as( select department,MAX(salary) as dept_sal FROM cte GROUP BY department HAVING department IN ('marketing','engineering') ),cte2 as( select cte1.*,LEAD(dept_sal)OVER() as second_dept_sal FROM cte1 ) select (dept_sal-second_dept_sal) as diff FROM cte2 where (dept_sal-second_dept_sal) is not null;
@ishamajumdar5580
@ishamajumdar5580 19 күн бұрын
WITH cte AS ( SELECT e.salary, ROW_NUMBER() OVER(PARTITION BY d.department ORDER BY salary DESC) AS rn FROM employee e JOIN dept d ON e.department_id = d.id WHERE d.department IN ('marketing', 'engineering') ) SELECT ABS(c1.salary - c2.salary) AS Absolute_diff FROM cte c1 JOIN cte c2 ON c1.rn = 1 AND c2.rn = 1 AND c1.salary > c2.salary;
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
Сестра обхитрила!
00:17
Victoria Portfolio
Рет қаралды 958 М.
RANK, DENSE_RANK, ROW_NUMBER SQL Analytical Functions Simplified
9:42
EY SQL Interview Question Solved Step-by-Step
10:10
The Data -Tech Club
Рет қаралды 150
5 Excel Secrets You'll Be Embarrassed You Didn't Know
17:32
Excel Campus - Jon
Рет қаралды 294 М.
Lead/Lag Window Analytical functions in SQL | Advance SQL concepts
10:34
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН