Sarbjit Parmar's Hello World
Menu

Another take at Pivoting Text data

9/24/2013

0 Comments

 
When I was interviewed the approach I took was on these lines:-

SELECT col1,
MAX(CASE WHEN rn = 1
      THEN col2 ELSE NULL
    END ) col21,
MAX(CASE WHEN rn = 2
    THEN col2 ELSE NULL
    END ) col22,
MAX(CASE WHEN rn = 3
      THEN col2 ELSE NULL
    END ) col23
FROM
(SELECT col1,col2,row_number() over (partition BY col1 order by col2) rn
  FROM test  
)
GROUP BY col1

The results were same as from the previous post
0 Comments

Your comment will be posted after it is approved.


Leave a Reply.

    About Sarbjit Parmar

    A practitioner with technical and business knowledge in areas of  Data Management( Online transaction processing, data modeling(relational, hierarchical, dimensional, etc.), S/M/L/XL/XXL & XML data, application design, batch processing, analytics(reporting + some statistical analysis), MBA+DBA), Project Management / Product/Software Development Life Cycle Management.

    Archives

    March 2018
    May 2016
    January 2015
    March 2014
    February 2014
    January 2014
    October 2013
    September 2013

    Categories

    All
    Acid
    Analytical Query
    Bigdata
    Columnar Database
    Compression
    Database
    Database Recovery
    Data Warehouse
    Data Warehouse
    Hierarchy
    Infogbright
    Informatica
    Interview
    Jboss
    Jgroups
    Job Scheduling
    Linux
    Mdm
    Metadata
    Normalization
    Oracle
    Performance Tuning
    Pivot
    PL/SQL
    Redo
    Repository
    Scheduler
    Siperian
    Sql
    Undo

    RSS Feed

Proudly powered by Weebly
  • Business
  • Technology
  • About
  • Business
  • Technology
  • About