Organizational Research By

Surprising Reserch Topic

pivot crosstab query in oracle 10g dynamic column number


pivot crosstab query in oracle 10g dynamic column number  using -'sql,oracle,pivot,transformation'

I have this table view

UserName      Product     NumberPurchaces
--------      -------     ---------------
'John Doe'    'Chair'     4
'John Doe'    'Table'     1
'Jane Doe'    'Table'     2
'Jane Doe'    'Bed'       1


How can I create a query that will provide this pivot view in Oracle 10g ?

 UserName   Chair   Table   Bed
 --------   -----   -----   ---
 John Doe   4       1       0
 Jane Doe   0       2       1


Any way to do it dynamically? I saw so many approaches (decode, PL/SQL loops, unions, 11g pivot)

But I've yet to find something that will work for me based on the above example



Edit: I don't know the number or type of products in development time so this has to be dynamic
    
asked Oct 7, 2015 by okesh.badhiye
0 votes
20 views



Related Hot Questions



Government Jobs Opening


...