I have two tables, Students
and Race
. Each student in the Students
table has one row. Each student in the Race
table has multiple rows, one for each race.
I'm trying to combine the tables into a view where I have one row for each student and each of their races are listed in separate columns; for example:
Any help or advice is greatly appreciated!
Best Answer
You will need to use the PIVOT function with a INNER JOIN to accomplish this:
If you are happy with just having the count as the row values then there is no need for the case statements and the query can be simplified to this: