SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Case when for multiple
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peace
Constraint Violating Yak Guru

278 Posts

Posted - 05/24/2012 :  02:58:26  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

Germany
8513 Posts

Posted - 05/24/2012 :  04:09:17  Show Profile  Visit webfred's Homepage  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.14 seconds. Powered By: Snitz Forums 2000