More Than One Counter In SQL Statementt

Posted on 2012-08-16
Last Modified: 2012-08-16

Please Consider the following SQL Statement:

sSQL = "Select SalLevel, Count(Gender = 'Male') As MaleCnt, Count(Gender = 'Female') As FemCnt From Employees  Group By SalLevel"

When I execute the above statement, I get the Grouping correct except that my FemCnt is Equal to my MaleCnt. And my MaleCnt is correct.

Can somebody please detect what I am doing wrong.

I am using VB.Net 2010 and running under Windows 7.

Many thanks
Question by:Nolanc
    LVL 25

    Accepted Solution

    try :
    Select SalLevel, 
           Sum(iif(Gender = 'Male',1,0)) As MaleCnt, 
           Sum(iif(Gender = 'Female',1,0)) As FemCnt 
    From Employees  
    Group By SalLevel

    Open in new window


    Author Closing Comment

    Hi lwadwell,

    Brilliant solution. Thank you.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
    In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
    In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now