I have a table in my database formatted like this:
customer old_code new_code
C1 A X
C1 B Y
C2 C Y
C2 D Z
So the pair of keys customer and old_code map to a new_code. This is great as a way of storing the data, looks ups are very fast, but for human consumption the data would be better displayed like this:
C1 C2
X A
Y B C
Z D
Is there an easy way using SQL to transform the data to the second view? Obviously there can be any number of customers although I could query for the unique set before hand. Currently I have < 50000 records and I expect that to be the norm but I'd like any solutions to scale up to a few hundred thousand if possible. My application currently targets MySQL.