View Single Post

   
  #2 (permalink)  
Old 02-28-2008, 07:32 PM
John Gilson
 
Posts: n/a
Default Re: query help - newbie

"vavavoomy2" <vavavoomy2@yahoo.com> wrote in message
news:c5e42899.0310251727.4c40229@posting.google.co m...
> Query: How many religions have N number of members?
> Table: Person table with Religion column. Each person has a religion value listed.
>
> How would I write this query in SQL?


DECLARE @n INT -- number of members in religion
SET @n = 100 -- for example
SELECT COUNT(*) AS religion_tally
FROM (SELECT Religion
FROM Person
GROUP BY Religion
HAVING COUNT(*) = @n) AS R

Regards,
jag


Reply With Quote