Posted in General

Miss. / Mrs. Stranger Email : Access Query

This email was about Access Query.

hi..
Plz check this question in dotnet spider on sqlserver.
http://www.dotnetspider.com/qa/Question19054.aspx
I need the output in access.I dont have proper touch
in access.Can u help this out by checking.

Thnks in advance.
keep smiling,
XXXXX.

The post talks about a database Table with CityName, PersonName and Sex (M/F). A person wants to get List of all cities and number of Males and Females in output. The person who sent me an email answered in the post with correct query. But she had troubles getting it in MS Access. This is how access we can write the query in Access. I checked it it works.


SELECT CityName, SUM(IsMale) As NoOfMales, SUM(IsFemale) As NoOfFemales
FROM (
SELECT CityName, IIF(Sex='M', 1,0)As IsMale, IIF(Sex='F', 1,0) as IsFemale
FROM Citytable
) GROUP BY CityName;

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s