Results 1 to 6 of 6
  1. #1
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108

    Help with SQL statement ( Query)

    Help me check if my sql statement is wrong




    Code:
    SELECT GROUPING.INSTITUTION, Count(GROUPING.GROUP_NO) AS NO_OF_GROUP
    FROM (SELECT GROUP_NO,CATEGORY, FIELDMATCHED,  INSTITUTION
    FROM CrossSystemData) AS GROUPING
    WHERE ((GROUPING.CATEGORY)="POTENTIAL DUP");
    Last edited by fluffyvampirekitten; 08-13-2015 at 04:00 AM.

  2. #2
    Mahendra1000 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2013
    Posts
    101
    What error is it getting?

  3. #3
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    Quote Originally Posted by Mahendra1000 View Post
    What error is it getting?

    This is the erro that I'm getting
    Your query does not include the specified expression "INSTITUTION" as part of an aggregate function

  4. #4
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Since your using the Count Function you also have to include a Group By Grouping.Institution after the where clause

  5. #5
    fluffyvampirekitten is offline Competent Performer
    Windows 7 64bit Access 2013
    Join Date
    Jun 2015
    Posts
    108
    Quote Originally Posted by RayMilhon View Post
    Since your using the Count Function you also have to include a Group By Grouping.Institution after the where clause
    It works! May i ask why i need to include it the Group By .....?
    So that I wont make the same mistake in the future.
    By the way , Thank you so much

  6. #6
    RayMilhon is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,071
    Because the count is an aggregate function so all fields in the query must be aggregated so if you're not counting, summing or aaggregating the data you must group the data

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

Similar Threads

  1. Replies: 1
    Last Post: 04-25-2015, 01:44 PM
  2. To import Excel data to a table in access through form.
    By vibinmvenugopal in forum Access
    Replies: 1
    Last Post: 09-26-2014, 06:24 AM
  3. VBA - Import Excel Data into Access Table
    By sikhinvestor in forum Import/Export Data
    Replies: 2
    Last Post: 04-28-2014, 01:43 PM
  4. Import Excel data into existing Access Table
    By octsim in forum Import/Export Data
    Replies: 4
    Last Post: 10-24-2013, 07:21 AM
  5. Replies: 5
    Last Post: 05-09-2013, 06:47 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