Hrm, you could do:

SELECT DISTINCT girl_name AS name, COUNT(girl_name) AS entries, "girl" AS
gender
FROM kidsnames
GROUP BY girl_name
UNION
SELECT DISTINCT boy_name AS name, COUNT(boy_name) AS entries, "boy" AS
gender
FROM kidsnames
GROUP BY boy_name
ORDER BY 2 DESC

but that doesn't limit you to five, or girls or boys, that's just going by
the numbers.

So I guess split it into two queries, like for one:

SELECT DISTINCT girl_name AS name, COUNT(girl_name) AS entries, "girl" as
gender
FROM kidsnames
GROUP BY girl_name LIMIT 5

but you'd have to use TOP instead of LIMIT if you're using MSSQL, for
example.

Bah. Simple queries, not very elegant.  Surely there are better, more
awesome ways to do it.
It will get you going, though, I guess.

HTH
:D

On 6/21/06, Mike | NZSolutions Ltd <[EMAIL PROTECTED] > wrote:
>
> Hi guys,
>
> I have a competition running for a client -
> http://www.eggmaternity.co.nz - to name their favourite baby names.
>
> My db consists of...
>
> entry_id
> Name_boy
> Name_girl
> Entry_name
> Entry_email
> Entry_country etc.
>
> I am just wondering how to display the results to the client eg. what
> query to use to show which are the most popular names.
>
> What I would like I think is to show the top 5 girls and top 5 boys
> names.
>
> If anyone could help me with the type of query I should be using it
> would be most appreciated.
>
> mike
>
>
>
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:244503
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to