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!

kind of transpose table

Discussion in 'SQL PL/SQL' started by ecivgamer, Sep 1, 2011.

  1. ecivgamer

    ecivgamer Active Member

    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    130
    Hi all!

    My need is to build columns for each month in table and find changes between monthes. My first try works fine, but next step should be performed using wider period.

    As you can see, I've got virtual table named jan2008, feb2008, mar2008, apr2008 left-joined to tt1 table.

    But what should I do with much more wider period, for example 5 years? Can I do it without creating virtual tables for each month?

    Oracle version: 11g
     
  2. ecivgamer

    ecivgamer Active Member

    Messages:
    73
    Likes Received:
    0
    Trophy Points:
    130
    Can I do the same without writing "date '2008-01-31' as p1, date '2008-02-29' as p2, date '2008-03-31' as p3" manually (it's simple for three months, but it's hard for 5 years period)?