I have a table which stores many codes for different systems. I would like to create a query to show every code for the 2 systems. For example, the data might look like this:
class[tab]code[tab]system
123[tab][tab]v1[tab]A
123[tab][tab]a2[tab]A
123[tab][tab]x1[tab]B
123[tab][tab]g2[tab]B
125[tab][tab]v1[tab]A
125[tab][tab]x1[tab]B
125[tab][tab]g2[tab]B
I would like my data to look like this:
Class[tab]ACode1[tab]Acode2[tab]BCode1[tab]Bcode2
123[tab][tab]v1[tab][tab][tab]a2[tab][tab][tab]x1[tab][tab][tab]g2
125[tab][tab]v1[tab][tab][tab]null[tab][tab][tab]x1[tab][tab][tab]g2
I am not sure how many different codes there would be, so i would need to dynamically create the code values for each system accross.
Would it be best that i create 2 separate cursors to loop through to create the headers and values accross and then join back to the table??
class[tab]code[tab]system
123[tab][tab]v1[tab]A
123[tab][tab]a2[tab]A
123[tab][tab]x1[tab]B
123[tab][tab]g2[tab]B
125[tab][tab]v1[tab]A
125[tab][tab]x1[tab]B
125[tab][tab]g2[tab]B
I would like my data to look like this:
Class[tab]ACode1[tab]Acode2[tab]BCode1[tab]Bcode2
123[tab][tab]v1[tab][tab][tab]a2[tab][tab][tab]x1[tab][tab][tab]g2
125[tab][tab]v1[tab][tab][tab]null[tab][tab][tab]x1[tab][tab][tab]g2
I am not sure how many different codes there would be, so i would need to dynamically create the code values for each system accross.
Would it be best that i create 2 separate cursors to loop through to create the headers and values accross and then join back to the table??