Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 4th, 2004, 08:43 PM
ironchef ironchef is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Cleveland
Posts: 112 ironchef User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 14 m 34 sec
Reputation Power: 6
sql query

simple query, but i keep getting stumped because i'm quite new at this...

I'm using Access 2000 - the database holds volunteer workers and their information.

I'm trying to write a simple query to count all the males and all the females.

The result should look like this:

Males: 130
Females: 300

For some reason access likes using "HAVING" instead of "WHERE". Is there a difference and what should I use?

Here's my code:

Code:
SELECT Volunteers.Gender, Count(Volunteers.Gender) AS TotalPerGender
FROM Volunteers
WHERE (((Volunteers.ADate)>=[forms]![Report Date Range]![BeginDate] And (Volunteers.ADate)<=[forms]![Report Date Range]![EndDate]))
GROUP BY Volunteers.Gender, Volunteers.StatusNo
HAVING (((Volunteers.StatusNo)=3));

Reply With Quote
  #2  
Old January 4th, 2004, 08:58 PM
r937's Avatar
r937 r937 is offline
SQL Consultant
Click here for more information.
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,913 r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level)r937 User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 4 Weeks 12 h 24 m 34 sec
Reputation Power: 1018
yes there is a difference, and you should use WHERE here
Code:
select Volunteers.Gender
     , Count(Volunteers.Gender) as TotalPerGender
  from Volunteers
 where Volunteers.ADate >= [forms]![Report Date Range]![BeginDate] 
   and Volunteers.ADate <= [forms]![Report Date Range]![EndDate]
   and Volunteers.StatusNo = 3
group
    by Volunteers.Gender
__________________
r937.com | rudy.ca

Reply With Quote
  #3  
Old January 4th, 2004, 10:44 PM
ironchef ironchef is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Cleveland
Posts: 112 ironchef User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 14 m 34 sec
Reputation Power: 6
thanks

worked! thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > sql query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT