1

Let say I have a TABLE called:

 EMP(Eid,Ename,ESalary)

Now I have to write a single query that will update:

if employee's salary >= 20000 then increment 25% else update 15% salary
0

2 Answers 2

3
update EMP
   set ESalary = CASE WHEN salary >= 20000
                      THEN salary * 1.25
                      ELSE salary * 1.15
                      END;
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Mate. i forgot about case
0

Try this:

update emp a set esalrary = 
(select (case when esalary >=20000 then esalary+(esalary*25/100) 
else  esalary+(esalary*25/100) end) from emp b where a.eid=b.eid);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.