Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010
    Posts
    2

    Unanswered: Transform columns into rows

    Hello,

    Im totally stuck with this problem. I have searched the solution in the forums but the things I saw didn`t work fine.

    I have this table:


    Code:
    ID | Total_time | Partial_time
    -----------------------------------------
    1         60            30
    and I want to transform if in this one:

    Code:
    ID | Parameter | Value
    ----------------------------------------
    1    Total_time      60
    1    Partial_time    30
    Any help? I guess that its not a difficult solution but I'm not able to find it.

    Thank you so much in advance.

    Edu[/code]

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Code:
    SELECT id
         , 'Total_time' AS parameter
         , Total_time AS value
      FROM daTable
    UNION ALL
    SELECT id
         , 'Partial_time'
         , Partial_time 
      FROM daTable
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2010
    Posts
    2
    Thank you so much, if works!!!

    Regards

Tags for this Thread

Posting Permissions

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