On 6/21/06, Mike Little <[EMAIL PROTECTED]> wrote:
>
> thanks denny,
>
> a little over my head but i will give them a go - haha.
Hehe. Here is a little fuller one
<cfquery name="count_girls" datasource="YourDataSource" maxrows="5">
SELECT DISTINCT
girl_name AS name,
COUNT(girl_name) AS entries,
"girl" as gender
FROM kidsnames
GROUP BY girl_name
ORDER BY COUNT(girl_name) DESC
</cfquery>
Just be sure to replace YourDataSource with your datasource,
and kidsnames with the name of your table.
The SQL says, grab me all DISTINCT names, and count each distinct name's #
of entries.
The DISTINCT probably isn't needed, actually, since the GROUP BY should take
care of it.
I added a column called gender with the value of "girl", just for kicks.
ORDER it BY
the number of entires, in DESCending order, from highest to lowest.
Here's a trimmer version:
<cfquery name="count_girls" datasource="YourDataSource" maxrows="5">
SELECT
girl_name,
COUNT(girl_name) AS entries
FROM kidsnames
GROUP BY girl_name
ORDER BY COUNT(girl_name) DESC
</cfquery>
If you're running something newer than CF 5, you can <cfdump
var="#count_girls#"> to see what the
resultset looks like.
Wash and repeat for boys, and you're in like Flynn. Probably better taking
the easy road and using
two queries, till you get comfortable with SQL.
**
Hrm... what's the winner get? Ah, NZ or AU only... Shucks.
My fiance could use some kick'n preggster dudz. ;-)
W00t for new life!
:]En
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:244514
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=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54