Using HAVING COUNT SQL to return specific results

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • benny1983
    New Member
    • Oct 2014
    • 25

    Using HAVING COUNT SQL to return specific results

    I have an audit report that opens based on a query of reviews for a certain quarter that have not been sent.

    The issue I am having is that I only want the clients name to come up on my report once the unsent audit count reaches 10 or more.

    Here is my SQL so far which works fine - I just need some guidance on only returning the result when the count of audits reaches 10+.

    I read about HAVING COUNT however cannot get that to function correctly. Any help is much appreciated.

    Code:
    SELECT DISTINCT tblQAAuditRecords20141.Provider
    FROM tblQAAuditRecords20141
    WHERE ((([tblQAAuditRecords20141].[QAQuarter])=[Enter QA Quarter]) And (([tblQAAuditRecords20141].[QAReportSent])=False))
  • benny1983
    New Member
    • Oct 2014
    • 25

    #2
    A bit of further research and came up with the following which works perfectly!

    Code:
    SELECT DISTINCT tblQAAuditRecords20141.Assessor, COUNT(Provider)
    FROM tblQAAuditRecords20141
    WHERE ((([tblQAAuditRecords20141].[QAQuarter])=[Enter QA Quarter]) And (([tblQAAuditRecords20141].[QAReportSent])=False))
    GROUP BY Provider
    HAVING COUNT(Provider) >9;

    Comment

    Working...