| Author |
Topic  |
|
|
AskSQLTeam
Ask SQLTeam Question
USA
0 Posts |
Posted - 02/08/2005 : 07:55:57
|
| sachin writes "we have employee table and we have to increment the salary of those employees getting salary greater than 3000, 3000 to 5000 and >5000 in a single query." |
|
|
Seventhnight
Flowing Fount of Yak Knowledge
USA
2878 Posts |
Posted - 02/08/2005 : 08:27:43
|
Something like this?
Update <table>
set
salary = salary + case
when salary < 3000 then 500
when salary between 3000 and 5000 then 1000
else 2000 end
From <table>
Where salary > 0
Corey
 "If the only tool you have is a hammer, the whole world looks like a nail." - Mark Twain |
 |
|
|
Xerxes
Aged Yak Warrior
USA
665 Posts |
Posted - 02/08/2005 : 09:22:39
|
Corey,
Uh, what if sachin had to do a lookup on another table to find that raise information? I have a similar problem like this .
Semper fi, Xerxes, USMC (Ret) |
 |
|
|
spirit1
Cybernetic Yak Master
Slovenia
11741 Posts |
Posted - 02/08/2005 : 09:34:45
|
join the second table to the first one and that's it.
Go with the flow & have fun! Else fight the flow  |
 |
|
|
Seventhnight
Flowing Fount of Yak Knowledge
USA
2878 Posts |
Posted - 02/08/2005 : 09:41:23
|
By the way, more relevant detail to a question, the better the answer! 
if you're still stuck give us some sample data to work with (with DDL and DML of course )
Corey
 "If the only tool you have is a hammer, the whole world looks like a nail." - Mark Twain |
 |
|
|
Xerxes
Aged Yak Warrior
USA
665 Posts |
Posted - 02/08/2005 : 09:52:31
|
I would elaborate if necessary, but spirit1's answer was exactly what I presumed it would be. Besides, since I discovered SQLTeam.com I've started applying much of what I've learned here and life has gotten a lot easier!
Thanks for the help!
Semper fi, Xerxes, USMC (Ret) |
 |
|
|
Seventhnight
Flowing Fount of Yak Knowledge
USA
2878 Posts |
Posted - 02/08/2005 : 10:09:08
|
quote: ... I've started applying much of what I've learned here and life has gotten a lot easier!
Thats the idea 
Corey
 "If the only tool you have is a hammer, the whole world looks like a nail." - Mark Twain |
 |
|
|
Xerxes
Aged Yak Warrior
USA
665 Posts |
|
| |
Topic  |
|