SQL Server Performance

Adding Rows

Discussion in 'General Developer Questions' started by Jeffrey_D_York, Jul 19, 2004.

  1. Jeffrey_D_York New Member

    Hi- Can anyone point me in the right direction on how to do the following.

    I have a table with the following example entries.

    WorkOrder STORE WO_Date LaborDolars PartsDollars

    123 FGO 5/22/2004 23.0000 72.0000
    123 FGO 5/22/2004 49.0000 16.0000
    123 FGO 5/29/2004 17.0000 24.0000
    124 FGO 5/22/2004 18.0000 32.0000

    I need to have one entry where WorkOrder+Store+WO_Date are identical, yet adding the
    Labor Dollars and PartsDollars for a cumulative value to be inserted into another table.

    My end result needs to be this for the 123 fgo 5/22/2004 entries:

    WorkOrder STORE WO_Date LaborDolars PartsDollars

    123 FGO 5/22/2004 72.0000 88.0000

    Any help is appreciated. Thanks!

  2. rlahoty New Member

    select workorder, store, wo_date, sum(labor_dollars), sum(parts_dollar)
    from <your_table>
    group by workorder, store, wo_date


    hth
    -rajeev lahoty

Share This Page