[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

More Than One Counter In SQL Statementt

Posted on 2012-08-16
2
Medium Priority
?
660 Views
Last Modified: 2012-08-16
Hi

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
0
Comment
Question by:Nolanc
2 Comments
 
LVL 25

Accepted Solution

by:
lwadwell earned 2000 total points
ID: 38303633
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

0
 

Author Closing Comment

by:Nolanc
ID: 38303679
Hi lwadwell,

Brilliant solution. Thank you.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

873 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