Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query Problem
Message
Information générale
Forum:
Microsoft Office
Catégorie:
Access
Titre:
Divers
Thread ID:
01520976
Message ID:
01520980
Vues:
20
>>>I'm trying to add WHERE e.IsActive to this query
>>>
>>>
>>>SELECT d.GroupId, 
>>>             Sum(d.cert_complete) AS SumOfcert_complete, 
>>>             Count(d.cert_complete) AS CountOfcert_complete
>>>    FROM (SELECT DISTINCT s.GroupId, e.EmployeeID, IIf(e.Certified Is Null,0,1) AS cert_complete 
>>>    FROM ((Stores AS s 
>>>    INNER JOIN EmployeeStores AS es ON s.StoreId=es.StoreId) 
>>>    INNER JOIN Employees AS e ON es.EmployeeId=e.EmployeeID) 
>>>    INNER JOIN Titles AS t ON e.TitleId=t.TitleId WHERE t.IsManager=True) as d
>>>    WHERE e.IsActive
>>>    GROUP BY d.GroupId
>>>UNION ALL SELECT 0 as GroupId, 
>>>       Sum(d.cert_complete) AS SumOfcert_complete, 
>>>       Count(d.cert_complete) AS CountOfcert_complete
>>>    FROM (SELECT DISTINCT s.GroupId, e.EmployeeID, IIf(e.Certified Is Null,0,1) AS cert_complete 
>>>    FROM ((Stores AS s 
>>>    INNER JOIN EmployeeStores AS es ON s.StoreId=es.StoreId) 
>>>    INNER JOIN Employees AS e ON es.EmployeeId=e.EmployeeID) 
>>>    INNER JOIN Titles AS t ON e.TitleId=t.TitleId WHERE t.IsManager=True)  AS d
>>>    WHERE e.IsActive
>>>
>>>
>>>When I add the WHERE clause and run it, I get prompted for "e.IsActive".
>>>
>>>What am I doing wrong here???>?
>>
>>Have you tried
>>
>>Where e.IsActive = 'true'
>>
>>? (or alternatively e.IsActive = 1) ?
>
>Yes I did. The syntax should be the same as the t.IsManager already in the query.

Ok, try:
SELECT d.GroupId, 
             Sum(d.cert_complete) AS SumOfcert_complete, 
        Count(d.cert_complete) AS CountOfcert_complete
   FROM (SELECT DISTINCT s.GroupId, e.EmployeeID, IIf(e.Certified Is Null,0,1) AS cert_complete 
    FROM ((Stores AS s 
    INNER JOIN EmployeeStores AS es ON s.StoreId=es.StoreId) 
    INNER JOIN Employees AS e ON es.EmployeeId=e.EmployeeID AND e.IsActive = True) 
    INNER JOIN Titles AS t ON e.TitleId=t.TitleId WHERE t.IsManager=True) as d
    GROUP BY d.GroupId
UNION ALL SELECT 0 as GroupId, 
       Sum(d.cert_complete) AS SumOfcert_complete, 
       Count(d.cert_complete) AS CountOfcert_complete
    FROM (SELECT DISTINCT s.GroupId, e.EmployeeID, IIf(e.Certified Is Null,0,1) AS cert_complete 
    FROM ((Stores AS s 
   INNER JOIN EmployeeStores AS es ON s.StoreId=es.StoreId) 
    INNER JOIN Employees AS e ON es.EmployeeId=e.EmployeeID AND e.IsActive = True) 
    INNER JOIN Titles AS t ON e.TitleId=t.TitleId WHERE t.IsManager=True)  AS d
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform