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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 update

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-03-09 : 08:47:32
sima writes "we hava a table containing salary field.we want to update the table in which that the salaries between 30000 to 40000 have a raising of 5000.the salaries between 50000 to 60000 hava a raising of 10000.how can we do it with some sql statements?"

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2006-03-09 : 09:08:15
[code]UPDATE SalaryTable
SET Salary = CASE
WHEN Salary BETWEEN 30000 AND 40000
THEN Salary + 5000
WHEN Salary BETWEEN 50000 AND 60000
THEN Salary + 10000
END
WHERE Salary BETWEEN 30000 AND 40000
OR Salary BETWEEN 50000 AND 60000[/code]

Assuming all other salaries stay as is.

Mark
Go to Top of Page
   

- Advertisement -