Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Sql determine rows that dont have value

I have a table that returns results like

abc   yes
abc   no
cdef  no
cdef  no
cdef  no
xyz   yes
xyz   no
xyz   no

sample query

with abc as(
select 'abc' as b , ' yes' as a
union all
select  'abc', 'no'
 
union all
select  'cdef', 'no'
union all
select  'xyz', 'no'
union all
select  'xyz', 'no'
)
 select * from abc

I want to return results that show accounts and indicate yes if they have a yes in any row and no if they dont so should look like this

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

abc yes
cdf no
xyz yes.

How can I do this?

>Solution :

A simple aggregation should do the trick.

Select Col1
      ,Col2 = max(Col2)
 From  YourTable
 Group By Col1
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading