I am trying to write a "crosstab" view on some joined tables, within an Oracle database. (I have already joined the tables in a view; now I would like to write a crosstab style view based on this view.) In MSAccess, this is ridiculously simple to do with a Crosstab query. In MSSQL (T-SQL), this is less easily done with several CASE statements. How could such a view be created in Oracle 8 (using ANSI-SQL)?
Just so I'm sure I'm making my question clear, here's the situation:
View 1 structure:
item_id item_attribute item_value
000001G i_a_1 d100
000001G i_a_2 e200
000001G i_a_3 f300
000001G i_a_4 g400
000001G ...
000002M i_a_1 d150
000002M i_a_2 e200
000002M i_a_3 f302
000002M i_a_4 g403
000002M ...
000003R i_a_1 d120
...
desired structure of needed crosstab view:
item_id i_a_1 i_a_2 i_a_3 i_a_4 ...
000001G d100 e200 f300 g400 ...
000002M d150 e200 f302 g403 ...
000003R d120 ...
...
Thank you! I apologize if this is a redundant or recurring topic. I searched the tek-tips site for a while before putting up the question. Any help is appreciated!
P.S. To head off possible obvious questions, I am aware of the denormalized table structure that the first view appears to be using. I am constrained to this table structure, unfortunately.
Just so I'm sure I'm making my question clear, here's the situation:
View 1 structure:
item_id item_attribute item_value
000001G i_a_1 d100
000001G i_a_2 e200
000001G i_a_3 f300
000001G i_a_4 g400
000001G ...
000002M i_a_1 d150
000002M i_a_2 e200
000002M i_a_3 f302
000002M i_a_4 g403
000002M ...
000003R i_a_1 d120
...
desired structure of needed crosstab view:
item_id i_a_1 i_a_2 i_a_3 i_a_4 ...
000001G d100 e200 f300 g400 ...
000002M d150 e200 f302 g403 ...
000003R d120 ...
...
Thank you! I apologize if this is a redundant or recurring topic. I searched the tek-tips site for a while before putting up the question. Any help is appreciated!
P.S. To head off possible obvious questions, I am aware of the denormalized table structure that the first view appears to be using. I am constrained to this table structure, unfortunately.