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 |
babloo
Starting Member
35 Posts |
Posted - 2012-12-13 : 10:11:02
|
Hi, I have some fields that I am trying to use in my Query. Is there a way I could do some kinda translation when I get my output such as:Select v_facility_code as [Facility],The values are 123 and abc, when I get 123 I want output to show Facility1, abc for Facility2.Same case for visit_admit_source as [Admit Source]Values are 2 digit alphabets, ex. NB, I want that to be translated to NewBornThanks alot. |
|
nigelrivett
Master Smack Fu Yak Hacker
3385 Posts |
Posted - 2012-12-13 : 10:14:13
|
select case v_facility_code when '123' then 'Facility1' when 'abc' then 'Facility2' else v_facility_code endfrom ...Would be better if these values were in a table then you could join to it.==========================================Cursors are useful if you don't know sql.SSIS can be used in a similar way.Beer is not cold and it isn't fizzy. |
|
|
babloo
Starting Member
35 Posts |
Posted - 2012-12-13 : 10:22:26
|
Thanks Nigelrivett. These values are already in a table. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-12-14 : 03:12:40
|
do a join likeSELECT columns...,m.Description,m1.Description,..FROM table tJOIN MappingTable mON m.ID = v_facility_codeJOIN MappingTable m1ON m1.ID = visit_admit_source... i've assumed column names so make sure you use actual columns inside------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|