locked
avoid null values and put all columns in one row RRS feed

  • Question

  • Hi all,

    I have result set from a select query like this;

    YrMonth       TotAcct        TotBadAcct      TotODS

    Jul 09         120               NULL                NULL

    July 09       NULL            110                  NULL

    July 09      NULL             NULL                200

    Aug 09      300              NULL                 NULL

    Aug 09      NULL             220                  NULL

    Aug 09      NULL            NULL                 110

    I wanna get the out put as follows;

    July 09     120            110                     200

    Aug 09      300           220                    110

    Can anyone help me how to write this code please?

     

    Thanks

     

     


    shamen
    Tuesday, August 24, 2010 4:31 AM

Answers

  • Select YrMonth, Max(TotAcct) As TotAcct,
     Max(TotBadAcct) As TotBadAcct, 
     Max(TotODS) As TotODS
    From <Your Tablee>
    Group By YrMonth
    
    Tom
    • Proposed as answer by Naomi N Tuesday, August 24, 2010 4:39 AM
    • Marked as answer by workplacemobbing Tuesday, August 24, 2010 4:47 AM
    Tuesday, August 24, 2010 4:35 AM