D
DArnold
I am new to Access so be gentle.
I have a query that pulls from 1 table:
Sales by month and sales for the year based on the clients STATUS:
When I try to put this into a report I keep geting the following error:
"Multi-level GROUP BY clause is not supported in a subquery"
The report shows:
Referral
January Status 1 1 for the month 5 for the year
January Status 2 3 for the month 4 for the year....
I would like to just have:
January:
Status 1 1 for the month 5 for the year
Status 2 3 for the month 4 for the
year....
February...
Status 1 1 for the month 5 for the year
Status 2 3 for the month 4 for the
year....
but it seems due to the query I can not group the months in the report.
Is there anyway around this or does the query need to be changed?
Here is the query:
SELECT
YEAR([Start Date]) AS RefYear,
MONTH([Start Date]) AS RefMonth,
FORMAT([Start Date],"mmmm") AS RefMonthName,
[Referral Source], Status,
COUNT(*) AS ReferralsForMonth,
(SELECT COUNT(*)
FROM
Patient AS P2
WHERE
YEAR(P2.[Start Date]) = YEAR(P1.[Start Date]) AND
P2.[Referral Source] = P1.[Referral Source] AND
P2.Status = P1.Status) AS ReferralsForYear
FROM
Patient AS P1
WHERE
YEAR([Start Date]) = [Enter year:]
GROUP BY
YEAR([Start Date]),
MONTH([Start Date]),
FORMAT([Start Date],"mmmm"),
[Referral Source], Status;
I have a query that pulls from 1 table:
Sales by month and sales for the year based on the clients STATUS:
When I try to put this into a report I keep geting the following error:
"Multi-level GROUP BY clause is not supported in a subquery"
The report shows:
Referral
January Status 1 1 for the month 5 for the year
January Status 2 3 for the month 4 for the year....
I would like to just have:
January:
Status 1 1 for the month 5 for the year
Status 2 3 for the month 4 for the
year....
February...
Status 1 1 for the month 5 for the year
Status 2 3 for the month 4 for the
year....
but it seems due to the query I can not group the months in the report.
Is there anyway around this or does the query need to be changed?
Here is the query:
SELECT
YEAR([Start Date]) AS RefYear,
MONTH([Start Date]) AS RefMonth,
FORMAT([Start Date],"mmmm") AS RefMonthName,
[Referral Source], Status,
COUNT(*) AS ReferralsForMonth,
(SELECT COUNT(*)
FROM
Patient AS P2
WHERE
YEAR(P2.[Start Date]) = YEAR(P1.[Start Date]) AND
P2.[Referral Source] = P1.[Referral Source] AND
P2.Status = P1.Status) AS ReferralsForYear
FROM
Patient AS P1
WHERE
YEAR([Start Date]) = [Enter year:]
GROUP BY
YEAR([Start Date]),
MONTH([Start Date]),
FORMAT([Start Date],"mmmm"),
[Referral Source], Status;