Or, here's another way, which resolves the potential ambiguity by giving preference to the first match in the case list:
Select ID
, Case when Input1 = 'yourvalue' then 'Input1'
when Input2 = 'yourvalue' then 'Input2'
when Input3 = 'yourvalue' then 'Input3'
when Input4 = 'yourvalue' then 'Input4'
End
From YourTable
Main Topics
Browse All Topics





by: dqmqPosted on 2006-05-24 at 17:27:12ID: 16756948
Sort of an inverse cross-tab :>).
Try:
Select 'Input1' from yourtable where Input1 = 'YourValue'
Union
Select 'Input2' from yourtable where Input2 = 'YourValue'
Union
Select 'Input3' from yourtable where Input3 = 'YourValue'
Union
Select 'Input4' from yourtable where Input4 = 'YourValue'