F
Frustrated in AL
Why does the SQL below return accurate data for the COUNT portion for
specific date range, but for the percentage portion, it divides the accurate
COUNT by the total from the entire table instead of the total for the date
range?
I have tried various suggestions, but cannot understand what is wrong. Can
someone explain it to me iin beginner terms, please? Thank you so much for
your time and patience.
PARAMETERS [Enter Start Date] DateTime, [Enter End Date] DateTime;
SELECT [Resolved by Hospice Date Worked].Responsibility, Count(*) AS [Number
of Appeals], Count(*)/(SELECT COUNT(*) FROM [Resolved by Hospice Date
Worked]) AS [% of All Appeals], Sum([Resolved by Hospice Date Worked].[Sales
Amount]) AS [Cost of Appeals], Sum([Sales Amount])/(SELECT SUM ([Sales
Amount]) From [Resolved by Hospice Date Worked]) AS [% of $$ All Appeals]
FROM [Resolved by Hospice Date Worked]
WHERE ((([Resolved by Hospice Date Worked].[Date Worked on]) Between [Enter
Start Date] And [Enter End Date]))
GROUP BY [Resolved by Hospice Date Worked].Responsibility;
I have the properties set for percentage so I do not need to multiply by 100
as I have seen done on previous suggestions.
specific date range, but for the percentage portion, it divides the accurate
COUNT by the total from the entire table instead of the total for the date
range?
I have tried various suggestions, but cannot understand what is wrong. Can
someone explain it to me iin beginner terms, please? Thank you so much for
your time and patience.
PARAMETERS [Enter Start Date] DateTime, [Enter End Date] DateTime;
SELECT [Resolved by Hospice Date Worked].Responsibility, Count(*) AS [Number
of Appeals], Count(*)/(SELECT COUNT(*) FROM [Resolved by Hospice Date
Worked]) AS [% of All Appeals], Sum([Resolved by Hospice Date Worked].[Sales
Amount]) AS [Cost of Appeals], Sum([Sales Amount])/(SELECT SUM ([Sales
Amount]) From [Resolved by Hospice Date Worked]) AS [% of $$ All Appeals]
FROM [Resolved by Hospice Date Worked]
WHERE ((([Resolved by Hospice Date Worked].[Date Worked on]) Between [Enter
Start Date] And [Enter End Date]))
GROUP BY [Resolved by Hospice Date Worked].Responsibility;
I have the properties set for percentage so I do not need to multiply by 100
as I have seen done on previous suggestions.