September 10th, 2000, 03:06 PM
Got a good one (or maybe I have just been working to hard)
I need to dive into a database that tracks hits on another database to see what is the most poular record (or recoreds).
I am using the following SQL code
_______ code _______
SELECT listingid,COUNT(*) from listingstats GROUP by listingid
_______ code end ________
This is getting me a count of all the items, and there respective hits, but it is not in any order of importance - if I order it in mysql, I can not order by the count.
Is there anyway I can use a SELECT statement like that to get a row selection from mySQL to where the item with the most rows (hits) would be the top and others following it in there hit aspects would be lower in a decreasing manner?
Any help would be appreciated.
September 10th, 2000, 04:06 PM
You could try this
SELECT listingid,COUNT(*) as numlistings from listingstats GROUP BY listingid ORDER BY numlistings DESC;
September 10th, 2000, 04:18 PM
Thanks man - worked like a charm... :-)
September 10th, 2000, 04:37 PM