Given the table foo:
Num Letter
------------
1 A
1 B
1 B
2 C
3 A
3 C
3 D
If I do SELECT * GROUP BY Num I of course get something like this:
Num Letter
------------
1 A
2 C
3 A
What I’d like to refine this to is:
Num Has_No_Letter_C
---------------------
1 Yes
2 No
3 No
There’s probably a simple SELECT IF () plus a ORDER BY, but I can’t see it right now…
In my real-world example, the resultant table is LEFT JOINed to another table and I want to be able to reject the No entries but keep the NULLs if my other table bar has a Num = 4 row.
Use
SUM(condition)within theIF:Your
JOINthen becomes: