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
 Case when for multiple

Author  Topic 

peace
Constraint Violating Yak Guru

420 Posts

Posted - 2012-05-24 : 02:58:26
I have a list to pull out as below:

One way : 1
Return : 2
Connecting bus : 3

so the sample will be out like this :

Bookingtype
1
2
3

Get from same table but different column, can I still pull the data into one column?
For now there are 3 different new column as I am having error to put in one column.

,CASE FareType
WHEN 'Connecting' THEN 3
ELSE FareJType
END
"Bookingtype"

,CASE TripType
WHEN 'return' THEN 2
ELSE TripType
END
"Bookingtype1"

,CASE TripType
WHEN 'oneway' THEN 1
ELSE TripType
END
"Bookingtype2"

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-05-24 : 04:09:17
You are not very clear about what you have and what you want.
So please give:
- table structure
- sample data
- wanted output
Make it simple


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

- Advertisement -