Results 1 to 7 of 7
  1. #1
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48

    Group by and count if "Male"

    Hi,



    I have a table with 2 columns:

    Company and Gender

    I would like to make a query which groups by Company and counts the values in column gender if gender value is "male"

    br Bertrand

  2. #2
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    I am VERY BAD at queries... but I think it would look like this..

    SELECT * FROM tablename
    WHERE Gender is LIKE "MALE" or 'MALE'
    GROUP BY Company

    if the database does not have alot of sensitive stuff post it on here and I will mess around with it

  3. #3
    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,726
    Try

    Code:
    SELECT Company
    , COUNT(*) as "Number of Males" 
    FROM YourTableNameHere 
    WHERE 
    gender = "male" 
    GROUP BY 
    Company;

  4. #4
    redbull's Avatar
    redbull is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Mar 2012
    Location
    Missouri
    Posts
    480
    Thank you orange, like I said I am very bad at queries... nice to know I was headed down the right road... sort of..

  5. #5
    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,726

  6. #6
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48
    Thank you, probloem solved with
    There are excellent examples at http://www.techonthenet.com/sql/index.php

  7. #7
    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,726
    Glad you got the problem solved.
    Don't overlook Google and Youtube for solutions to Access, SQL and Database issues.

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

Similar Threads

  1. Replies: 4
    Last Post: 04-07-2012, 02:33 PM
  2. Replies: 1
    Last Post: 03-30-2011, 06:16 PM
  3. "Group By" causes "ODBC--Call Failed" error
    By kaledev in forum Queries
    Replies: 1
    Last Post: 03-09-2011, 02:43 PM
  4. Query Table for "*" and then Count all instances
    By Steven.Allman in forum Queries
    Replies: 14
    Last Post: 09-10-2010, 07:45 PM
  5. "Count" and "Countif" in Reports
    By JMantei in forum Reports
    Replies: 1
    Last Post: 06-20-2006, 02:20 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