|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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)); |
|
#2
|
||||
|
||||
|
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
|
|
#3
|
|||
|
|||
|
thanks
worked! thanks
|
![]() |
| Viewing: Dev Shed Forums > Databases > Database Management > sql query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|