J
JensB
I got this nice pease of SQL from Duane
Showing the total for each valid quote:
SELECT Sum([quotelines].[TotalPrice]) AS tPrice,quotehead.QuoteNo
FROM Quotehead INNER JOIN QuoteLines ON Quotehead.id =
QuoteLines.QuoteHeadID
WHERE (((quotehead.ID) In (SELECT TOP 1 ID FROM quotehead O WHERE
O.CustNo = quotehead.CustNo and O.TrackNo = quotehead.TrackNo ORDER BY
QuoteNo Desc)))
ORDER BY quotehead.CustNo, quotehead.TrackNo;
When I use above SQL on these rows
CustNo QuoteNo TrackNo (tPrice)
200 10 10 1000(Sum from
quotelines)
200 10-a 10 2000 -"-
200 10-b 10 500 -"-
300 20 20 1000 -"-
400 30 30 1500 -"-
400 30-a 30 300 -"-
I get this result:
200 10-b 10 2000
300 20 20 1000
400 30-a 30 300
My new question is:
Is it posible to the get the sum of the result( 200, 300 and 400) = 3300
with one query on all rows?
Jens
Showing the total for each valid quote:
SELECT Sum([quotelines].[TotalPrice]) AS tPrice,quotehead.QuoteNo
FROM Quotehead INNER JOIN QuoteLines ON Quotehead.id =
QuoteLines.QuoteHeadID
WHERE (((quotehead.ID) In (SELECT TOP 1 ID FROM quotehead O WHERE
O.CustNo = quotehead.CustNo and O.TrackNo = quotehead.TrackNo ORDER BY
QuoteNo Desc)))
ORDER BY quotehead.CustNo, quotehead.TrackNo;
When I use above SQL on these rows
CustNo QuoteNo TrackNo (tPrice)
200 10 10 1000(Sum from
quotelines)
200 10-a 10 2000 -"-
200 10-b 10 500 -"-
300 20 20 1000 -"-
400 30 30 1500 -"-
400 30-a 30 300 -"-
I get this result:
200 10-b 10 2000
300 20 20 1000
400 30-a 30 300
My new question is:
Is it posible to the get the sum of the result( 200, 300 and 400) = 3300
with one query on all rows?
Jens