Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How To Add Sum
Message
General information
Forum:
Microsoft Office
Category:
Access
Title:
Miscellaneous
Thread ID:
01516559
Message ID:
01516561
Views:
26
>I have this query:
>
>
>SELECT q.GroupId, 
>       (SumOfcert_complete/CountOfcert_complete)*100 AS Percent_Certified, 
>       Groups.GroupName
>    FROM qryGroupCert_base AS q 
>    INNER JOIN Groups ON q.GroupId=Groups.GroupId
>
>
>It results in
>
>
>GroupId	percent_certified	GroupName
>286	           58            Group A
>287	           58 	         Group B
>288	          100	         Group C
>289	          100	         Group D
>
>
>I would like to add a summary row that shows the total percentage, so that I would end up with
>
>
>GroupId	percent_certified	GroupName
>286	           58            Group A
>287	           58 	         Group B
>288	          100	         Group C
>289	          100	         Group D
>0                 315            All
>
>
>So far I tried this:
>
>
>SELECT q.GroupId, 
>      (SumOfcert_complete/CountOfcert_complete)*100 AS percent_certified,
>      (Sum(SumOfcert_complete/CountOfcert_complete)*100)) / 4 AS Total,
>      Groups.GroupName
>FROM qryGroupCert_base AS q INNER JOIN Groups ON q.GroupId=Groups.GroupId;
>
>
>but it's not quite right. What's wrong here?


There is no GROUP BY clause :-)
You can't get a TOTAL on the same row w/o using subquery or derived table.
Try
SELECT q.GroupId, 
      (SumOfcert_complete/CountOfcert_complete)*100 AS percent_certified,
      Total.Total,
      Groups.GroupName
FROM qryGroupCert_base AS q
INNER JOIN Groups ON q.GroupId=Groups.GroupId;
CROSS JOIN (SELECT Sum(SumOfcert_complete/CountOfcert_complete)*100)) / 4 AS Total
                   FROM qryGroupCert_base) Total
NOT TESTED!!!
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform