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 |
maevr
Posting Yak Master
169 Posts |
Posted - 2013-04-09 : 09:22:52
|
I have a table that i need to iterate through and return Yes or Noif a column contains the value 91 or 99.The column has multiple rows with the same id but if the column col1 contains 91 or 99 then it should return 'Yes' otherwise No. Only one value should be returned.Example table:id col11 001 962 913 003 99Expected output: 1 No2 Yes3 Yes |
|
singularity
Posting Yak Master
153 Posts |
Posted - 2013-04-09 : 09:58:33
|
[code]select id, max(case when col1 in ('91','99') then 'Yes' else 'No' end) as flagfrom yourtablegroup by id[/code] |
|
|
|
|
|