Results 1 to 2 of 2
  1. #1
    coach32 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    47

    Counting figures between values


    My database contains a list of values such as:
    2
    6
    9
    15
    12
    7
    4
    How do I create a query that will count and show the number of figures between the following values
    0 - 7 (Equals 3)
    8 - 14 (Equals 2)
    15-21 (Equals 1)
    Is this possible? Thank you in advance for any assistance.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Create three calculated expressions to see what range they fall in, then make it an Aggregate Query (summing each expression).
    You can do that right in the Query Builder. The resulting SQL Code would look something like this:
    Code:
    SELECT 
        Sum(IIf([MyTable]![MyValue]>=0 And [MyTable]![MyValue]<=7,1,0)) AS [0-7], 
        Sum(IIf([MyTable]![MyValue]>=8 And [MyTable]![MyValue]<=14,1,0)) AS [8-14], 
        Sum(IIf([MyTable]![MyValue]>=15 And [MyTable]![MyValue]<=21,1,0)) AS [15-21]
    FROM 
        MyTable;

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

Similar Threads

  1. Counting values after a specific value
    By cardgage in forum Queries
    Replies: 5
    Last Post: 03-12-2013, 07:41 AM
  2. Replies: 21
    Last Post: 11-07-2012, 02:14 PM
  3. Counting text values
    By Fish218 in forum Queries
    Replies: 3
    Last Post: 07-27-2012, 09:44 AM
  4. counting values
    By webisti in forum Access
    Replies: 1
    Last Post: 11-18-2011, 07:28 AM
  5. help counting distinct values
    By joo-joo-man in forum Queries
    Replies: 2
    Last Post: 10-17-2010, 05:18 AM

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