Reputation: 11
I tried this query, but I'm stuck in the where
condition. Can anybody help me how to update the salary for the whose joined last 6 years?
Query:
update emp
set sal=sal+3000
where doj=(select doj from emp where doj)
Upvotes: 0
Views: 315
Reputation: 121
You can use "between" clause
update emp
set sal=sal+3000
where doj between dateadd(year, -6, getdate()) and getdate()
Upvotes: 0
Reputation: 1
update emp
set sal=sal+3000
where datediff(doj,select getdate(),yy)<=6
Upvotes: -1
Reputation: 981
update emp
set sal=sal+3000
where doj=(select doj from abd where datepart(year,doj) between 2009 and 2015)
Upvotes: 0
Reputation: 5161
Hopefully this will help :)
update emp set sal=sal+3000 where doj>=sysdate-6*365 and doj<sysdate;
Upvotes: 2
Reputation: 7766
update emp
set sal = sal + 3000
where select datediff(day,doj,Getdate()) / 365.2425 >= 6
Upvotes: 1