Results 1 to 2 of 2
  1. #1
    Vistaz is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Oct 2012
    Posts
    7

    Access query


    hi there,

    I am confused here, please help me out.

    1. I have table with Date of birth, Occupational level etc. i need to calculate the age as it today.
    2. i have calculated the age now i need to group by occupational level, and for each age mybe 5 people have 57 years. i need to calculate the percentage for that number of employees within that age.

    here is my query:

    SELECT Age_Anaylsis.OccpLvl, (Age_Anaylsis.Age) As Age, Count(Age_Anaylsis.Age) AS Number_Of_Employees
    FROM Age_Anaylsis
    GROUP BY Age_Anaylsis.OccpLvl, Age_Anaylsis.Age;

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,441
    if you're determined to do this in a query as opposed to a report or a form (where it's easier to deal with) you'll have to use domain functions (look at dsum, dcount, dmax, dmin, etc)

    in your case you'd have another field that's dcount("*", "[EmployeeTable]") as TotalEmployees.

    If you want a criteria on your dcount, for instance let's say you have an 'active' flag for people who are currently employed only you'd have something like

    dcount("*", "[EmployeeTable]", "[ActiveFlag] = 'A'") as TotalEmployees

    Just be very, very cautious about using domain functions in queries, they are incredibly memory intensive because basically for every record of your query it is performing the exact same function over and over and over. Domain functions can be very handy but they will bloat your database pretty quickly especially with larger datasets.

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

Similar Threads

  1. Replies: 3
    Last Post: 04-24-2012, 08:32 AM
  2. Replies: 34
    Last Post: 02-15-2012, 05:17 AM
  3. Replies: 12
    Last Post: 05-22-2011, 03:49 PM
  4. Convert Access query to SQL Server query
    By mkallover in forum Queries
    Replies: 2
    Last Post: 05-13-2011, 06:20 AM
  5. Replies: 10
    Last Post: 02-02-2011, 05:48 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