Garren.Shannon
Member
- Local time
- Today, 11:47
- Joined
- Sep 22, 2022
- Messages
- 113
Hey all,
I have to report the top 3 headcount days to the state for 3 count-periods during the year... FirstCount (Sept 1 to Oct 31), SecondCount (Nov 1 to Jan 31st) and LastCount (Feb 1 to Apr 30th).
I have a query that lists all the bus trips between date X to end date Y. All trips have a total headcount (Max Count) for the trip. I need to tally up all the headcounts by day, then report the top 3 days to the state for the count period (First, Second or Last).
So if Sept 11th had 65 trips with a total headcount of 1030 and Sept 4th had 67 trips with total headcount of 1032 and Oct 5th had 64 trips with at total headcount of 1041 and Oct 29 had a total headcount of 1035, I would report Sept 4th (1032), Oct 5th (1041) and Oct 29 (1035).
I think this would be a crosstab query but I can't figure out how to build this. Would I build the initial query to sum by date for max count, then build a crosstab from that query? Or do I need a summation query first, then build a crosstab from that?
Here's the SQL for the current query. It gives me a list of trips by date with the max headcount per trip.
SELECT Trip.[T-Date], Trip.MaxCount, SchoolYrDates.SchoolYear
FROM Trip, SchoolYrDates
WHERE (((Trip.[T-Date]) Between [SchoolYrDates]![CountStartDate] And [SchoolYrDates]![FirstCount]) AND ((SchoolYrDates.SchoolYear)=GetCurrentYear()));
Any help is appreciated.
I have to report the top 3 headcount days to the state for 3 count-periods during the year... FirstCount (Sept 1 to Oct 31), SecondCount (Nov 1 to Jan 31st) and LastCount (Feb 1 to Apr 30th).
I have a query that lists all the bus trips between date X to end date Y. All trips have a total headcount (Max Count) for the trip. I need to tally up all the headcounts by day, then report the top 3 days to the state for the count period (First, Second or Last).
So if Sept 11th had 65 trips with a total headcount of 1030 and Sept 4th had 67 trips with total headcount of 1032 and Oct 5th had 64 trips with at total headcount of 1041 and Oct 29 had a total headcount of 1035, I would report Sept 4th (1032), Oct 5th (1041) and Oct 29 (1035).
I think this would be a crosstab query but I can't figure out how to build this. Would I build the initial query to sum by date for max count, then build a crosstab from that query? Or do I need a summation query first, then build a crosstab from that?
Here's the SQL for the current query. It gives me a list of trips by date with the max headcount per trip.
SELECT Trip.[T-Date], Trip.MaxCount, SchoolYrDates.SchoolYear
FROM Trip, SchoolYrDates
WHERE (((Trip.[T-Date]) Between [SchoolYrDates]![CountStartDate] And [SchoolYrDates]![FirstCount]) AND ((SchoolYrDates.SchoolYear)=GetCurrentYear()));
Any help is appreciated.