Loading ...
Sorry, an error occurred while loading the content.

1864Re: [SQLQueriesNoCode] How to form pivot table

Expand Messages
  • filzah hanani
    Jan 16, 2006
    • 0 Attachment
      try
      select type,qty,station,expense from tablename group by type

      pengbsam <pengbsam@...> wrote:
      I am kind of new at it. Only been working with SQl for couple of
      month. and I have a weired questions! I have a results view such as
      below

      type         Qty    station                   expenses        
      ------------ ------ ---------------------- -----------
      business     0002   station1                  18722      
      business     0002   station2                  9564       
      business     0002   station3                  24278      
      business     0002   station4                  375        
      business1    0003   station1                  19566      
      business1    0003   station2                  NULL     
      business1    0003   station3                  12066      
      business1    0003   station4                  12875   

      but actually I need to turn into format such as

      type         Qty    station                  expenses        
      ------------ ------ ---------------------- -----------
      business     0002   station1                  18722      
                          station2                  9564       
                          station3                  24278      
                          station4                  375        
      business1    0003   station1                  19566      
                          station2                  NULL     
                          station3                  12066      
                          station4                  12875   

      Because if I don't then who ever going to use the query gonna
      suspect that they quantity is 8 and 12 pcs where it's actually 2pcs 
      3 pcs, respectively! Could somebody help me out? I really
      appreciated it! Thank you!






      Yahoo! Photos
      Got holiday prints? See all the ways to get quality prints in your hands ASAP.

    • Show all 7 messages in this topic