Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2003
    Posts
    74

    Unanswered: How can I realize the interchange between row and column in a SQL statement?

    example:

    month value
    ===========
    10 100
    11 200
    12 205



    10 11 12
    ===========
    100 200 205

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    If it is a month-value pair, you may use

    select sum(case month when 1 then value end) as 1,
    sum(case month when 2 then value end) as 2,
    ....
    ....
    sum(case month when 12 then value end) as 12
    from table1

    HTH

    sathyaram
    Visit the new-look IDUG Website , register to gain access to the excellent content.

  3. #3
    Join Date
    Jan 2003
    Posts
    74
    That's right!! Thank you very much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •