How to select row data as column in Oracle -


i have 2 tables bellow shows figures

enter image description here

enter image description here

i need select records bellow shown figure. ah_id need join in second table , att_id column header , att_dtl_str_value need column relevant value

required output

enter image description here

sounds have entity-attribute-value data model relational dbs aren't best @ modeling. may want key-value store.

however, justin suggested, if you're using 11g can use th pivot clause follows:

select * (       select t1.ah_id, t1.ah_description, t2.att_id, t2.att_dtl_str_value       t1          left outer join t2 on t1.ah_id = t2.ah_id      ) pivot (max(att_dtl_str_value) (att_id) in (1)); 

this statement requires hard-code in att_id there ways dynamically. more info can found here.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -