1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

need to create report in Oracle SQL using dynamic pivot tab

Discussion in 'Other Databases' started by ktk, Jul 19, 2013.

  1. ktk

    ktk Guest

    I have a table tab1 which contains columns Cust, ProdSeq, StartDat, EndDat, AttrId, AttrValue.
    I can have different attributes represented by attrId (say 1,2,3,4..etc.,) and its value by AttrValue respectively.
    My question is for a given a customer, prodSeq and date range say 01-Jan-2013 to 31-Jan-2013, I want a report like below

    Example input data
    CUST PRODSEQ STARTDAT ENDDAT ATTRID ATTRVALUE
    C1 1 1/1/2013 1/15/2013 1 1
    C1 1 1/1/2013 1/10/2013 2 A
    C1 1 1/1/2013 3 X
    C1 1 1/1/2013 4 G
    C1 1 1/11/2013 1/31/2013 2 B
    C1 1 1/16/2013 1/20/2013 1 2
    C1 1 1/21/2013 1/31/2013 1 3


    Expected output
    CUST PRODSEQ STARTDAT ENDDAT ATTR1VAL ATTR2VAL ATTR3VAL ATTR4VAL
    1 1 01-JAN-2013 10-01-2013 1 A X G
    1 1 11-JAN-2013 15-01-2013 1 B X G
    1 1 16-JAN-2013 20-01-2013 2 B X G
    1 1 21-JAN-2013 31-01-2013 3 B X G


    I tried pivot table concept in Oracle, but unfortunately, ATTRVALUE is the one which needs to be pivoted. Its values are not fixed and unknown while writing the query. Any help would be appreciated
     
  2. shreya92

    shreya92 Active Member

    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    80
    Check out rolta, which might help you with a solution to your query with a suitable option.
    Also you could check the other services they render for everyone, with a faster reach and satisfying consumers by useful data which is actually required for the particular project or an organization.
    check out the website : rolta.com/services/oracle-applications/
     
  3. shreya92

    shreya92 Active Member

    Messages:
    26
    Likes Received:
    0
    Trophy Points:
    80
    Check out rolta, which might help you with a solution to your query with a suitable option.
    Also you could check the other services they render for everyone, with a faster reach and satisfying consumers by useful data which is actually required for the particular project or an organization.
    check out the website : rolta.com/services/oracle-applications/