I have table in SQL Server 2005 that contains two columns Fruit and Colour as shown below
Fruit Colour
Apple Red
Orange Red
Berry Green
PineApple Green
Now i want to convert it into an adjacency matrix query
as shown below
Red Green
Apple 1 0
Orange 1 0
Berry 0 1
PineApple 0 1
what i want to do is give 1 if Fruit and Colour are there
else i want to give a 0
It was hard to avoid those null values in the pivot.
Output