Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2005-02-08 : 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
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-02-08 : 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 endFrom <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
666 Posts |
Posted - 2005-02-08 : 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
11752 Posts |
Posted - 2005-02-08 : 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
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-02-08 : 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
666 Posts |
Posted - 2005-02-08 : 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
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2005-02-08 : 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
666 Posts |
|
|
|
|
|
|