View Full Version : Query By Total


mtagliaferri
07-05-2009, 05:17 AM
Hi, I am trying to have a total for every record as a SUM of the value and all grouped by the same PSR record.
For example I have many records that have the same PSR value (2009 04 – 2009 05 – 2009 06....ect..) I would like to return only one record for 2009 04 one for 2009 05 and so on with all the totals of the relatives colums.
Here is the SQL query:
SELECT tblFlight.IDTrip, Int(Sum(tblFlight.FlightTime)*24) & ":" & Format(Sum(tblFlight.FlightTime),"nn") AS [Tot Flying Time], Count(tblFlight.IDTrip) AS [Tot Sectors], Count(tblFlight.Duty) AS [Non Operating Sectors], [Tot Sectors]-[Non Operating Sectors] AS [Operating Sectors], tblTrip.PSR
FROM tblTrip INNER JOIN tblFlight ON tblTrip.IDTrip = tblFlight.IDTrip
GROUP BY tblFlight.IDTrip, tblTrip.PSR;

Can I get some help?
Thanks

GalaxiomAtHome
07-05-2009, 06:19 AM
If I understand correctly you want to produce grouped results and then total the columns.

Leave out all the Totals from the query. Just group by the PSR.
Set the query as the RecordSource for your report or form.
Add text boxes with the Total expressions as their Control Source.

for example:
Control Source: =Sum(fieldname)