Results 1 to 2 of 2
  1. #1
    dfenton21 is offline Novice
    Windows XP Access 97
    Join Date
    May 2011
    Posts
    6

    Order By Subquery

    I have a question that I can't find the answer to.

    I have the following:



    Code:
    SELECT DISTINCT
    
    Staff.Manager, 
    
    (SELECT COUNT(Manager) 
    FROM 
    Audit 
    WHERE 
    Comment = 'Warning' AND Manager = Staff.Manager) AS Occurances
    
    FROM Staff
    I want to sort the result by Occurances. I understand that I can't use an alias in the ORDER BY clause. I tried copying the sub query into the ORDER BY clause, but that gave me a syntax error message.

    Any advice on how to achive this would be greatly appreciated.
    Thanks

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    first of all, why is there a subquery here? it's not needed:

    Code:
    select manager, count([comment])
    from audit
    where comment = "warning"
    group by manager

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

Similar Threads

  1. TOP subquery
    By helpaccess in forum Queries
    Replies: 5
    Last Post: 08-30-2011, 10:28 AM
  2. Subquery and IIF statement
    By ksamaniego in forum Queries
    Replies: 1
    Last Post: 08-15-2011, 03:17 PM
  3. Subquery sum?
    By anemoskkk in forum Access
    Replies: 0
    Last Post: 04-29-2011, 12:36 PM
  4. Subquery
    By combine21 in forum Queries
    Replies: 2
    Last Post: 09-17-2010, 04:33 PM
  5. Problem with subquery
    By bakerdenn in forum Queries
    Replies: 1
    Last Post: 04-24-2009, 10:37 PM

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