Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Old Forums
 CLOSED - General SQL Server
 My Question
 Forum Locked
 Printer Friendly
Author Previous Topic Topic Next Topic  

AskSQLTeam
Ask SQLTeam Question

USA
0 Posts

Posted - 02/08/2005 :  07:55:57  Show Profile  Visit AskSQLTeam's Homepage
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  Show Profile  Visit Seventhnight's Homepage
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
Go to Top of Page

Xerxes
Aged Yak Warrior

USA
666 Posts

Posted - 02/08/2005 :  09:22:39  Show Profile
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)
Go to Top of Page

spirit1
Cybernetic Yak Master

Slovenia
11752 Posts

Posted - 02/08/2005 :  09:34:45  Show Profile  Visit spirit1's Homepage
join the second table to the first one and that's it.

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Seventhnight
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 02/08/2005 :  09:41:23  Show Profile  Visit Seventhnight's Homepage
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
Go to Top of Page

Xerxes
Aged Yak Warrior

USA
666 Posts

Posted - 02/08/2005 :  09:52:31  Show Profile
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)
Go to Top of Page

Seventhnight
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 02/08/2005 :  10:09:08  Show Profile  Visit Seventhnight's Homepage
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
Go to Top of Page

Xerxes
Aged Yak Warrior

USA
666 Posts

Posted - 02/08/2005 :  10:33:27  Show Profile
Corey,

FYI....I praised your expertise in my latest here: http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=44434


Semper fi,

Xerxes, USMC (Ret)
Go to Top of Page
  Previous Topic Topic Next Topic  
 Forum Locked
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.13 seconds. Powered By: Snitz Forums 2000