oracle - Transpose unknown number of columns with single row result using dynamic PL/SQL -


i believe there must simple way achieve this, haven't been figure out. i've search ways can't find doesn't invlovle aggregates,

i have dynamic query (oracle) build in loop using configuration tables following form:

select         b1.id1,         b2.id2,        ...         table_a a,         table_b b1,         table_b b2,         ...         a.id = a_variable   , (    b1.value (+)= a.column1         , b2.value (+)= a.column2        ...); 

i expect return single row, otherwise throw error. i'm looking have result this:

--------------- |id  | value  | --------------- |id1 |      9 | |id2 |      8 | |id3 |   null | |id4 |      6 | |...          | --------------- 

instead of:

----------------------------- |id1  | id2 | id3 | id4 | ... ----------------------------- |   9 |   8 | null|   6 | ... ----------------------------- 

thanks in advance!!

just simple unpivot @ end of dynamic query:

select * your_query unpivot include nulls (   "value" id in (id1 ,id2 ,id3 ,id4) ) 

demo: http://sqlfiddle.com/#!4/10c35/2


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -