I need help to write this in SQL:
I have one table and I would like to select No with Chars A, B or C, but if I have A and B for same No I want to show only B, else I need to show all.
Pseudo code:
SELECT *
FROM Table1
WHERE IF EXISTS (Char = A and Char = B)
THEN Char IN (B, C)
ELSE Char IN (A, B, C)
Example:
Table1
ID No Char
1 10 A
2 10 B
4 10 C
5 11 A
6 11 D
7 12 C
I want result:
ID No Char
2 10 B
4 10 C
5 11 A
7 12 C
Is it clear enough what I need?