0
votes

Input.

Key---- id---- ind1 ----ind2
1       A          Y         N
1       B         N        N
1       C         Y        Y
2      A         N         N
2       B        Y        N

Output

Key ind1 ind2
1    Y       Y
2      Y     N

So basically whenever the ind1..n col is y for same key different id . The output should be y else N.

That why for key 1 both ind is y And key 2 ....ind is y and n.

1

1 Answers

0
votes

You can use max() for this:

select id, max(ind1), max(ind2)
from t
group by id;