Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Counting records, group by, order by

0 views
Skip to first unread message

blackandwhite

unread,
Jan 7, 2008, 5:55:42 AM1/7/08
to
Hi All,

I'm trying to display the "top 5" images downloaded from our site. I've
attached the code I'm currently working with.

All seems fine except I can't "order by" results from the count value "numImg"

Any ideas?

Cheers

Trevor

<CFQUERY NAME="GetImg" DATASOURCE="uka_comments">
SELECT strImage, COUNT(*) AS numImg FROM multimedia_feedback
GROUP BY strImage
ORDER BY strImage
</CFQUERY>

<cfoutput query="GetImg"><IMG SRC="multimedia/mm_images/#strImage#"><br
/></cfoutput>

GArlington

unread,
Jan 7, 2008, 7:13:16 AM1/7/08
to
On Jan 7, 10:55 am, "blackandwhite" <webforumsu...@macromedia.com>
wrote:

You can always do QoQ over your GetImg results...

BKBK

unread,
Jan 7, 2008, 7:12:40 AM1/7/08
to
<CFQUERY NAME="GetImg" DATASOURCE="uka_comments">
SELECT strImage, COUNT(*) AS numImg
FROM multimedia_feedback
GROUP BY strImage
ORDER BY [i]numImg[/i]
</CFQUERY>

blackandwhite

unread,
Jan 7, 2008, 7:28:56 AM1/7/08
to
I found and implemented the following solution:

<CFQUERY NAME="GetImg" DATASOURCE="uka_comments">

select strImage, count(strImage) as entries from multimedia_feedback group by
strImage order by count(strImage) DESC
</CFQUERY>

Works a treat.

Cheers

Trevor


0 new messages