October 3, 2002 at 1:32 pm
I would like to create a field/expression that would calculate the sum of a couple other fields? Is that possible or is that best left for VB code?
here is my sql statement right now:
SELECT drivernum,Sum(fuelchrg),Sum(tractorcost),Sum(CashAdvAmt),Sum(cashadvchrg),Sum(totamtdue),Sum(oilcost) from fuelinvoice group by drivernum
So I want to add the sums of all those fields for my gtotal field.
Matt
October 3, 2002 at 1:58 pm
SELECT drivernum,Sum(fuelchrg),Sum(tractorcost),Sum(CashAdvAmt),Sum(cashadvchrg),Sum(totamtdue),Sum(oilcost) ,
Sum(fuelchrg)+Sum(tractorcost)+Sum(CashAdvAmt)+Sum(cashadvchrg)+Sum(totamtdue)+Sum(oilcost) as gTotal
from fuelinvoice group by drivernum
with rollup
ROLLUP generates a result set showing aggregates for a hierarchy of values in the selected columns. VAlue of drivernum will be null
I hope this answers your question.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply