How do I calculate in a query?

pdbowling

Registered User.
Local time
Today, 23:22
Joined
Feb 14, 2003
Messages
179
This query

SELECT DISTINCTROW [companyGraphData].[Dept], Sum([companyGraphData].[TotalRep]) AS [Sum Of Rep], Sum([companyGraphData].[TruckCount]) AS Trucks
FROM companyGraphData
GROUP BY [companyGraphData].[Dept];

gives me this table

Dept Sum of Rep Trucks
data data data

How could I modify it to include an additional column that would be sum of Rep divided by trucks to get an average per truck.
Thanks
PB
 
pdbowling said:
How could I modify it to include an additional column that would be sum of Rep divided by trucks to get an average per truck.
Thanks
PB

Try:

SELECT DISTINCTROW [companyGraphData].[Dept],
Sum([companyGraphData].[TotalRep]) AS [Sum Of Rep],
Sum([companyGraphData].[TruckCount]) AS Trucks,

(Sum([companyGraphData].[TotalRep]) / Sum([companyGraphData].[TruckCount])) AS [AvgPerTruck]

FROM companyGraphData
GROUP BY [companyGraphData].[Dept];

Line breaks are for emphasis/clarity only--put it all together.

--Division-By Mac
 

Users who are viewing this thread

Back
Top Bottom