Results 1 to 2 of 2
  1. #1
    zephaneas is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2008
    Posts
    15

    Problem Adding WHERE Clause

    In my query shown below, I just want to add "WHERE e.IsActive = True" and when I do, I'm getting prompted for "e.IsActive".



    What am I doing wrong??

    Code:
     
    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) 
        WHERE e.IsActive = 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) 
        INNER JOIN Titles AS t ON e.TitleId=t.TitleId WHERE t.IsManager=True) 
        WHERE e.IsActive = True
     AS d;

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,530
    If my eye is working correctly, "e" is defined within the subquery, but you're trying to use it in the outer query.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using the TOP clause
    By WSlepecki in forum Queries
    Replies: 1
    Last Post: 04-08-2011, 06:59 AM
  2. Adding an additional WHERE clause
    By Pells in forum Queries
    Replies: 7
    Last Post: 10-28-2010, 12:44 PM
  3. IIF clause
    By Peljo in forum Queries
    Replies: 2
    Last Post: 02-05-2008, 11:22 AM
  4. problem adding properties to a access db
    By dnzone in forum Programming
    Replies: 0
    Last Post: 10-03-2006, 11:02 PM
  5. Help on WHERE clause
    By QBCM in forum Programming
    Replies: 1
    Last Post: 12-19-2005, 08:43 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums