Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Addring Rows

Author  Topic 

Jeffrey_D_York
Starting Member

2 Posts

Posted - 2004-07-19 : 10:32:15
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!

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-07-19 : 10:34:42
Group By


Sekect
WorkOrder,
STORE,
WO_Date,
LaborDollars = sum(LaborDollars),
PartsDollars = sum(PartsDollars)
From yourTable
Group By WorkOrder, STORE, WO_Date




Corey
Go to Top of Page
   

- Advertisement -