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
 General SQL Server Forums
 New to SQL Server Programming
 creating new column based on where statement

Author  Topic 

boehnc
Starting Member

15 Posts

Posted - 2012-02-01 : 13:11:00
I have a Where statement that looks at around 3 different sets of diagnosis codes.

I place all the codes in my where statement, but I want another column that will indicate which set they come from.

I guess I can create a lookup table and do a join, but was wondering if there was a way to use code in my query? Thanks for any info.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-01 : 13:13:17
sorry can you elaborate with some sample data and show how you want output?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

boehnc
Starting Member

15 Posts

Posted - 2012-02-01 : 15:07:06
sure. 523.1 and 253.1 is CABG, 112.2 is Cardiac, 156.3 and 234.4 are low back. I wanted in column 2 to display the Group to which the code belongs. (there might be 20 or 25 different codes per group, but this is a simple example).

column1, column2
523.1, CABG
253.1, CABG
523.1, CABG
112.2, Cardiac
112.2, Cardiac
156.3, Low Back
234.4, Low Back

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-02-01 : 15:13:30
thats what its currently displaying isnt it?
isnt the group code also in the same table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -