Results 1 to 3 of 3

Thread: Showing SQL Result [solved]

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Posts
    335

    Showing SQL Result [solved]

    Hello
    I have an Access database where I have a field named "parSex" where it is holding participants gender (sex) as M or F

    Now I want to run an sql statement in Access to count the number of Males and females and show the result as

    M F
    xx yy

    When I use

    SELECT TRG_PARTICIPANTS.parSex, Count(TRG_PARTICIPANTS.parSex) AS CountOfparSex
    FROM TRG_SESSION INNER JOIN TRG_PARTICIPANTS ON TRG_SESSION.sessionId = TRG_PARTICIPANTS.sessionId
    GROUP BY TRG_PARTICIPANTS.parSex;

    I get this

    ParSex Count
    M xx
    F yy

    Thanks in advance
    Last edited by bell; May 29th, 2008 at 07:16 AM. Reason: solved
    Please Help Each other.
    if you can't at least
    Do not Hurt Each Other

  2. #2
    Head Hunted anhn's Avatar
    Join Date
    Aug 2007
    Location
    Australia
    Posts
    3,669

    Re: Showing SQL Result

    Code:
    SELECT -SUM(TRG_PARTICIPANTS.parSex="M") AS Males, 
    -SUM(TRG_PARTICIPANTS.parSex="F") AS Females
    FROM TRG_SESSION INNER JOIN TRG_PARTICIPANTS 
    ON TRG_SESSION.sessionId = TRG_PARTICIPANTS.sessionId;
    • Don't forget to use [CODE]your code here[/CODE] when posting code
    • If your question was answered please use Thread Tools to mark your thread [RESOLVED]
    • Don't forget to RATE helpful posts

    • Baby Steps a guided tour
    • IsDigits() and IsNumber() functions • Wichmann-Hill Random() function • >> and << functions for VB • CopyFileByChunk

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 2001
    Posts
    335

    Re: Showing SQL Result [resolved]

    Thanks it worked
    Please Help Each other.
    if you can't at least
    Do not Hurt Each Other

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width