I've got 2 crosstab queries that both work, but I'd like to combine them together.
The first shows the total time that various vehicles were used for at each base:
The second shows the number of trips that each vehicle did at various bases:
What I'd ideally like is to generate one crosstab that shows both the combined time and the number of trips for each vehicle at the various bases. Is this possible? The above queries maxed out my very limited abilities on SQL!
I'd like to end up with something like this:
The first shows the total time that various vehicles were used for at each base:
Code:
TRANSFORM Sum(Cdbl(Nz(M.dtTripTime, 0))) AS SheetTime
SELECT M.lngVehicleID
,Sum(Cdbl(Nz(M.dtTripTime, 0))) AS Total
FROM tblSheets M
INNER JOIN Bases B ON M.lngBaseID = B.BaseID
GROUP BY M.lngVehicleID
PIVOT B.BaseName IN (
'ALPHA'
,'BRAVO'
,'CHARLIE'
);
The second shows the number of trips that each vehicle did at various bases:
Code:
TRANSFORM Count(M.lngSheetID) AS SheetCount
SELECT M.lngVehicleID
,Sum(Cdbl(Nz(M.dtTripTime, 0))) AS Total
FROM tblSheets M
INNER JOIN Bases B ON M.lngBaseID = B.BaseID
GROUP BY M.lngVehicleID
PIVOT B.BaseName IN (
'ALPHA'
,'BRAVO'
,'CHARLIE'
);
What I'd ideally like is to generate one crosstab that shows both the combined time and the number of trips for each vehicle at the various bases. Is this possible? The above queries maxed out my very limited abilities on SQL!
I'd like to end up with something like this: