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 |
satheesh
Posting Yak Master
152 Posts |
Posted - 2011-08-15 : 06:09:43
|
Dear allI have a table quote with destination and trip fields.I need to select productname with some conditionCondition :-If Destination is (AreaOne or AreaTwo ) and trip is 'single' then productname as EuropeExcessIf Destination is (AreaThree or Areafour ) and trip is 'Annual' then productname as WorldEXCESSHow to do this.Any help is highly appreciated.Many ThanksRegards,SGDesired ResultDestination Trip ProductAreaOne Single EuropeExcessAreaTwo Single EuropeExcessAreaThree Annual WorldEXCESS |
|
Devart
Posting Yak Master
102 Posts |
Posted - 2011-08-15 : 07:05:45
|
Hi,For example:SELECT ..., CASE WHEN Destination IN ('AreaOne','AreaTwo') AND Trip = 'single' THEN 'EuropeExcess' WHEN Destination IN ('AreaThree','AreaFour') AND Trip = 'Annual' THEN 'WorldEXCESS' END AS ProductName ...FROM <your_table_name>Devart,SQL Server Tools:dbForge Data StudiodbForge Schema ComparedbForge Data ComparedbForge SQL Complete |
|
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2011-08-15 : 07:41:24
|
Thank You Devart.Its Working :-) |
|
|
|
|
|