P
prismlight
Hello,
I was hoping someone could help a newbie.
I have a table named FSAClients with Feilds such as EthnicGroup, StartMonth,
StartYear,EndMonth,EndYear. Im trying to get my query results to calculate
the sums of both the Total and Percent Columns ( sum of Total column will
always vary but the Percent column should always appear as 100%) Also, how
would the query appear if I wanted Each EthnicGroups to appear in the results
even if the total was 0?Here is my query and the results thus far (Thank to
John V. and Bill).
(Thanks in advance)
Query:
PARAMETERS [Begin Date] DateTime, [End Date] DateTime;
SELECT FSAClients.EthnicGroup, Count(*) AS Total, Count(*)/(SELECT Count(*)
FROM FSAClients WHERE DateSerial([StartYear], [StartMonth], 1) <= [End Date]
And (DateSerial([EndYear], [EndMonth]+1, 1) - 1) >= [Begin Date]) AS
PercentByGroup
FROM FSAClients
WHERE (((DateSerial([StartYear],[StartMonth],1))<=[End Date]) AND
((DateSerial([EndYear],[EndMonth]+1,1)-1)>=[Begin Date]))
GROUP BY FSAClients.EthnicGroup;
Query Results:
EthnicGroup Total PercentByGroup
Asian American 1 10.00%
Caucasian 5 50.00%
Latino 3 30.00%
Pacific Island 1 10.00%
I was hoping someone could help a newbie.
I have a table named FSAClients with Feilds such as EthnicGroup, StartMonth,
StartYear,EndMonth,EndYear. Im trying to get my query results to calculate
the sums of both the Total and Percent Columns ( sum of Total column will
always vary but the Percent column should always appear as 100%) Also, how
would the query appear if I wanted Each EthnicGroups to appear in the results
even if the total was 0?Here is my query and the results thus far (Thank to
John V. and Bill).
(Thanks in advance)
Query:
PARAMETERS [Begin Date] DateTime, [End Date] DateTime;
SELECT FSAClients.EthnicGroup, Count(*) AS Total, Count(*)/(SELECT Count(*)
FROM FSAClients WHERE DateSerial([StartYear], [StartMonth], 1) <= [End Date]
And (DateSerial([EndYear], [EndMonth]+1, 1) - 1) >= [Begin Date]) AS
PercentByGroup
FROM FSAClients
WHERE (((DateSerial([StartYear],[StartMonth],1))<=[End Date]) AND
((DateSerial([EndYear],[EndMonth]+1,1)-1)>=[Begin Date]))
GROUP BY FSAClients.EthnicGroup;
Query Results:
EthnicGroup Total PercentByGroup
Asian American 1 10.00%
Caucasian 5 50.00%
Latino 3 30.00%
Pacific Island 1 10.00%