Results 1 to 5 of 5
  1. #1
    PMV1964 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Posts
    3

    Post Find the most popular answer in a field


    Hi I'm using Access 2013 with a basic knowledge of Access.
    I have a report that that will bring up a list of data. In that data is a field that has a production run size. In the footer I have worked out the max run size / min run size / average run size. What I need to know is can I get the most occurring run size? So to find the run size most used.
    Thanks in advance

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    in a query do a COUNT of the field, (or SUM if numeric)

    sort descending

  3. #3
    PMV1964 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Posts
    3
    Quote Originally Posted by ranman256 View Post
    in a query do a COUNT of the field, (or SUM if numeric)

    sort descending
    I don't think this is quite right,
    for example in the report there is 10 records with 2,000 in this field and 12 records with 7,000, 7 with 7,500 and 8 with 9,000.
    Min = 2,000 - which I can do
    Max = 9,000 - which I can do

    Most = 7,000 which I can't do

  4. #4
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    See this query which will give the value with the highest count.(most replicated value)
    Code:
    SELECT Table1.myField, Count(Table1.myField) AS CountOfmyField
    FROM Table1
    GROUP BY Table1.myField
    ORDER BY Count(Table1.myField) DESC;
    This is based on a Table TABLE1
    with fields
    ID autonumber PK
    MyField Number

    MyField valued as per your sample.

    Result:
    myField CountOfmyField
    7000 12
    2000 10
    9000 9
    7500 7

    You can do it with one query if you modify the previous example to
    Code:
    select top 1 * from 
    (SELECT Table1.myField, Count(Table1.myField) AS CountOfmyField
    FROM Table1
    GROUP BY Table1.myField
    ORDER BY Count(Table1.myField) DESC);
    to give this result
    Code:
    myField CountOfmyField
    7000 12

  5. #5
    PMV1964 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Jul 2015
    Posts
    3

    Smile

    Quote Originally Posted by orange View Post
    See this query which will give the value with the highest count.(most replicated value)
    Code:
    SELECT Table1.myField, Count(Table1.myField) AS CountOfmyField
    FROM Table1
    GROUP BY Table1.myField
    ORDER BY Count(Table1.myField) DESC;
    This is based on a Table TABLE1
    with fields
    ID autonumber PK
    MyField Number

    MyField valued as per your sample.

    Result:
    myField CountOfmyField
    7000 12
    2000 10
    9000 9
    7500 7

    You can do it with one query if you modify the previous example to
    Code:
    select top 1 * from 
    (SELECT Table1.myField, Count(Table1.myField) AS CountOfmyField
    FROM Table1
    GROUP BY Table1.myField
    ORDER BY Count(Table1.myField) DESC);
    to give this result
    Code:
    myField CountOfmyField
    7000 12

    Thanks for your help - took a little time to get my head around it, but now I totally understand the process and it gives me the answers I require

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

Similar Threads

  1. the ever popular if>then statement
    By sbrady19 in forum Forms
    Replies: 19
    Last Post: 02-25-2015, 11:49 AM
  2. Please help me find answer for question 2
    By florida2001 in forum Access
    Replies: 3
    Last Post: 04-04-2014, 06:34 PM
  3. Replies: 5
    Last Post: 04-24-2012, 10:26 AM
  4. Database challenge: can you find the answer?
    By Cholomanchuten in forum Access
    Replies: 5
    Last Post: 08-05-2011, 12:27 PM
  5. Make new field based on previous field's answer
    By VictoriaAlbert in forum Access
    Replies: 1
    Last Post: 04-11-2011, 09:54 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