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)
 Assigning values based on another value

Author  Topic 

LOLCatLady
Starting Member

24 Posts

Posted - 2010-10-21 : 10:02:50
I have a table with a column that contains an amount. I want to add a column with a value assignment based on the amount column. For example, I want the value "1" assigned to all records that are in the .01 - 9.99 range.

What's the best way to do this?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-21 : 10:21:08
Add the new column using ALTER TABLE.
Update the TABLE setting the new column to the needed value.
If the posted condition is the only one then use the WHERE clause.
If there are multiple conditions then use a CASE expression.

If that isn't clear to you then give more info please (DDL, sample data, wanted resuelt).


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

LOLCatLady
Starting Member

24 Posts

Posted - 2010-10-21 : 15:49:25
Excellent! Thanks for your help.



quote:
Originally posted by webfred

Add the new column using ALTER TABLE.
Update the TABLE setting the new column to the needed value.
If the posted condition is the only one then use the WHERE clause.
If there are multiple conditions then use a CASE expression.

If that isn't clear to you then give more info please (DDL, sample data, wanted resuelt).


No, you're never too old to Yak'n'Roll if you're too young to die.

Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-10-22 : 02:23:32
welcome


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -