F
Frustrated in AL
I have a query based on a table that will continue to have data added to it.
The query in question is based on date parameters. The actual "Count" is
accurate for number of appeals and cost of appealsbroken down by different
responsibility. The problem is with the percentages. I am not getting the
percentages for the specified date range [count by responsiblitity for date
range/date range total]. Instead, the query is using the totals for the
entire table [count by responsiblitity for date range/total table count].
Can someone please assist me, once again, in understanding where I am going
wrong? I have included the SQL and a query where the date range excludes the
last week in the query, showing correct totals for the time period but
percentatges based on all data on the table.
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;
Resp #Appeals % Appeals Cost of Appeals % of $$ All Appeals
? 1 0.07%
CON 8 0.59% $122.00 0.12%
CSR 84 6.19% $3,205.24 3.19%
HOS 58 4.27% $2,744.20 2.73%
NOC 701 51.66% $32,583.29 32.44%
OTH 72 5.31% $4,501.57 4.48%
The query in question is based on date parameters. The actual "Count" is
accurate for number of appeals and cost of appealsbroken down by different
responsibility. The problem is with the percentages. I am not getting the
percentages for the specified date range [count by responsiblitity for date
range/date range total]. Instead, the query is using the totals for the
entire table [count by responsiblitity for date range/total table count].
Can someone please assist me, once again, in understanding where I am going
wrong? I have included the SQL and a query where the date range excludes the
last week in the query, showing correct totals for the time period but
percentatges based on all data on the table.
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;
Resp #Appeals % Appeals Cost of Appeals % of $$ All Appeals
? 1 0.07%
CON 8 0.59% $122.00 0.12%
CSR 84 6.19% $3,205.24 3.19%
HOS 58 4.27% $2,744.20 2.73%
NOC 701 51.66% $32,583.29 32.44%
OTH 72 5.31% $4,501.57 4.48%