How to select row data as column in Oracle -
i have 2 tables bellow shows figures
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
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
Post a Comment