How to transpose this table ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pdiagne83
    New Member
    • Mar 2012
    • 1

    #1

    How to transpose this table ?

    I have this table
    custid visitid pagenum pagename
    001 1 1 acceuil
    001 1 2 produit
    001 2 1 home
    002 1 3 rayon
    002 1 4 rayon
    001 2 2 produit
    003 1 1 home

    I want to convert the above table in the following form:

    custid visitid page1 page2 page3 page4
    001 1 acceuil produit null null
    001 2 home produit null null
    002 1 null null rayon rayon
    003 1 home null null null

    and at end

    custid visitid page
    001 1 acceuil>produit
    001 2 homme>produit
    002 1 rayon>rayon
    003 1 home

    I look forward to your reply. THANKS
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Pivot the data and then coalesce() the fields.

    Comment

    Working...