Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2005

    Unanswered: How to display rows as columns

    Hi everyone. I need some help formating the output of my query. My query currently displays multiple charge items per trip in multiple rows. What I want to be able to do is display these rows in columns so that I only have one distinct row containing all the information. Please see below. Thanks in advance for everyones help.

    Current results

    Trip Charge Rate
    123 Shipping 500.00
    123 FSC 35.00
    456 Shipping 750.00
    456 FSC 45.00

    I want to be able to display my output in columns

    Trip Shipping_Charge FSC
    123 500.00 35.00
    456 750 45.00

  2. #2
    Join Date
    Feb 2004
    In front of the computer
    Provided Answers: 54
    Normally I'm terribly suspicious of posts like this... This kind of question at this time of year is almost always homework. For some weird reason I can't identify, I'm willing to give you a straight answer.
    SELECT trip
    ,  Sum(CASE WHEN 'Shipping' = Charge THEN rate END) AS Shipping_Charge
    ,  Sum(CASE WHEN 'FSC' = Charge THEN rate END) AS FSC
       GROUP BY Trip

Posting Permissions

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