Link to home
Start Free TrialLog in
Avatar of Jeremy Campbell
Jeremy CampbellFlag for United States of America

asked on

Need help troubleshooting Access Query SQL

I managed to get this working with just the one join but can't seem to add the second one in.

Here is the code;
SELECT A.UserCount, C.NotifyCount
FROM 
(
SELECT 1 AS Num, Count(B.tblCurrentUsers.UserID) AS UserCount 
   FROM (
   SELECT tblCurrentUsers.UserID, tblCurrentUsers.AppType, Max(tblCurrentUsers.DateTime) AS MaxOfDateTime, Last(tblCurrentUsers.LogType) AS LastOfLogType FROM tblCurrentUsers GROUP BY 1,          
   tblCurrentUsers.UserID, tblCurrentUsers.AppType HAVING (((Last(tblCurrentUsers.LogType))="LogOn"))
   )  AS B
)  AS A 

LEFT JOIN 

(
SELECT 1 AS Num, Count(D.tblNotifications.Read) AS NotifyCount 
   FROM 
   (
   SELECT tblNotifications.Read 
   FROM tblNotifications WHERE (((tblNotifications.Read)=False))
   )  AS D
)  AS C 

ON A.Num = C.Num

LEFT JOIN

(
SELECT 1 AS Num, Count(E.tblEnhance.ID) AS EnhanceCount
FROM
   (
   SELECT tblEnhance.ID
   FROM tblEnhance
   WHERE (((tblEnhance.Completed)=False))
   ) AS E
) AS F

ON A.Num = F.Num

Open in new window


Here is the error;
User generated image
Thanks in advance for the help!
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

I'll bite.  

I don't see an ON clause anywhere that relates B to A, D to C, and F to E.
if you remove line 13-24 (and first line make it "select *"), does it run?
ASKER CERTIFIED SOLUTION
Avatar of Jeremy Campbell
Jeremy Campbell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Jeremy Campbell

ASKER

Figured it out.

Thanks for your input though fellows!