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 |
|
dhinasql
Posting Yak Master
195 Posts |
Posted - 2008-06-07 : 08:27:35
|
| Hi Friends,I have a sql table, Named as tbl_Property, i have the column names are id,swimming,club,parking. [ Here swimming , club , parking are bit data type ]The database will be filled with the following sample dataid Swimming Club Parking1 0 1 12 1 1 13 0 0 0Here i want to select property details by id, and which are the fields have 1 data, i want to select that column name.Expected output for id=1 isClub ParkingExpected output for id=2 isSwimming Club ParkingPlease help me how to do this?Thanks in Advance |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-07 : 09:41:49
|
| [code]SELECT CASE WHEN Swimming=1 THEN 'Swimming ' ELSE '' END +CASE WHEN Club=1 THEN 'Club ' ELSE '' END +CASE WHEN Parking=1 THEN 'Parking' ELSE '' ENDFROM Table WHERE id=@ID[/code] |
 |
|
|
|
|
|