My base table is like:
ColumnA|ColumnB
---------------
A | C1
A | C2
A | C3
B | C1
B | C3
C | C4
I want to read records from the base table and write it into the below table:
ColumnA | C1 | C2 | C3 | C4
----------------------------
A | Y | Y | Y | N
B | Y | N | Y | N
C | N | N | N | Y
I don’t want to use a cursor, but I don’t know if that’s possible or not.
Thanks
One (usually fast) way would be
group by:Another way is subqueries, like:
Or, adapted from Chris Diver’s answer, with
pivot: