Query to find amout of salary hike

In table "salary" with emp_no,sal_dt,salary which records salary of all employees every month.find the query to give the amount of salary hike and date of hike for all the employees.

Showing Answers 1 - 4 of 4 Answers

mohit.gamer

  • Dec 18th, 2007
 

Here is the Answer to the above Query:

select s01.empno, s02.salarydt, (s02.salary-s01.salary) SalaryHike
from salary01 S01
inner join
(select empno, salarydt, salary from salary01) S02
on s01.empno = s02.empno
where datediff(mm, s01.salarydt, s02.salarydt) = 1
and (s02.salary-s01.salary) > 0

  Was this answer useful?  Yes

ramkrishnag

  • Oct 17th, 2008
 

Select distinct S1.empno , s2.sal_date , (s2.sal-s1.sal) Salhike from salary s1 , salary s2
where s1.empno = s2.empno and (s2.sal-s1.sal) > 0

Above results in all hikes of all employees

  Was this answer useful?  Yes

ngiridhar

  • Oct 26th, 2010
 

SELECT empno,
DECODE
(SIGN ( salary

- LEAD (salary, 1, 0) OVER (ORDER BY empno DESC,
sal_dt DESC)
),
-
1, 'LAST',
salary
- LEAD (salary, 1, 0) OVER (ORDER BY empno DESC, sal_dt DESC)
) AS sal_diff

FROM salary

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions