Results 1 to 8 of 8
  1. #1
    tkandy is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2011
    Posts
    4

    Grouping of data

    I have a table with the following



    Name, SName, DOB, Area, Gender


    From the DOB field i get the age, and i want to be able to show a grouping for each area with the following count in catagories. And males and females

    17-25yrs, 26-35yrs, 36-45yrs, 46+yrs and Total



    So something like this

    17-25 yrs 26-35yrs 36-45yrs 46+Yrs Total
    Females 5 2 7
    Males 6 3 9
    Total 11 3 2 0 16
    Last edited by tkandy; 05-09-2011 at 03:23 PM. Reason: Setting out in what i would like to see

  2. #2
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    What have you got so far?

  3. #3
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by kennejd View Post
    What have you got so far?
    I LIKE this!!! Kudos to this post!!!

  4. #4
    LionKing is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Apr 2011
    Posts
    3
    tkandy,

    FYI
    1. try to search first in google/microsoft on how to get the age
    2. use if's.... iif getAge >=17 and age <=25,"17-25yrs", iif getAge >=26 and age <=35,"26-35yrs",....... as AgeBracket; sum(iif(gender = "F",1,0)) as TotalFemale; sum(iif(gender = "M",1,0)) as TotalMale GROUP BY agebracket...
    3. use different query or function to get the overall total

  5. #5
    kennejd is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    188
    I can't claim originality....I seem to have seen similar posts from some 'aje' guy...

  6. #6
    tkandy is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2011
    Posts
    4
    Thank you to all that posted, i started doing seperate queries for each one as i am not fluent i knew their would be a better way

    the row that is like this i did have it in a table (17-25 yrs 26-35yrs36-45yrs46+YrsTotalFemales527Males639Total 1132016)
    i have now changed this to look like this


    17-25 yrs 26-35yrs 36-45yrs 46+Yrs Total
    Females 5 2 7
    Males 6 3 9
    Total 11 3 2 0 16

  7. #7
    tkandy is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Mar 2011
    Posts
    4
    Hi Lion king

    I already have the age sorry i missed this bit field out sorry.

  8. #8
    LionKing is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Apr 2011
    Posts
    3
    Hello tkandy,

    Okay.. good if you have already function to get the age...

    In your new sequence of age columns... same thing you have to do... in your query to group the ages..
    (use SELECT ang GROUP BY query)

    (column1) 17-25yrs: iif(getAge >=17 and age <=25,1,0)
    (column2) 26-35yrs: iif getAge >=26 and age <=35,1,0)
    (column3) ......
    replace group by with sum

    you can include totals if do you want...

    (column 5) Females: iif(Gender = "f",1,0)
    (column 6) Males: iif(Gender = "m",1,0)
    replace group by with sum

    For total
    Option 1 (with age limit):
    (column 7) Total: iif(getAge >= 17,1,0)
    replace group by with sum

    Option 2 (no age limit):
    (column 8) Total: Gender
    replace group by with count

    if you are going to use total in form or report separately:
    Females: dcount("[gender]","table_name","[gender] = 'F'")
    Males: dcount("[gender]","table_name","[gender] = 'M'")
    Total: dcount("*","table_name", "getAge([dob])>= 17") // with age limit
    Total: dcount("*","table_name") // no age limit

    good luck!

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

Similar Threads

  1. Grouping reports
    By jfrazer22 in forum Reports
    Replies: 1
    Last Post: 08-26-2010, 01:18 PM
  2. Grouping By Age
    By xnixiel in forum Queries
    Replies: 1
    Last Post: 07-01-2010, 09:14 AM
  3. Grouping
    By dref in forum Reports
    Replies: 1
    Last Post: 01-16-2010, 08:30 AM
  4. Grouping from several comparisons
    By piflechien73 in forum Queries
    Replies: 3
    Last Post: 05-26-2009, 04:15 PM
  5. Grouping data in Report
    By Leelers in forum Reports
    Replies: 1
    Last Post: 02-20-2009, 08:49 AM

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