PHP-Nut Posted November 13, 2007 Share Posted November 13, 2007 ??? I have a database holding a list of customer`s orders, i thought it would be neat to show the top 5 selling products on our website. Now i have a recordset that counts each product sold which COUNTS by model_ID and GROUPS BY model_ID But heres the problem i wish to show the highest COUNT descending?? So the highest COUNT is at the top and show five records giving me the Top 5 Selling models? At the moment it lists them in model order as you would expect.. here is the rough Recordset:- SELECT *, COUNT(mode_ID) FROM order_item,products WHERE products.prod_ID=order_item.mode_ID GROUP BY mode_ID ??? Thanks Paul. Quote Link to comment Share on other sites More sharing options...
Adam Posted November 13, 2007 Share Posted November 13, 2007 I imagine you'd have to look into using "JOIN" .. to join the select and the count queries.. then i reckon you might be able to order them by the count. Search google for "JOIN". - Adam Quote Link to comment Share on other sites More sharing options...
PHP-Nut Posted November 13, 2007 Author Share Posted November 13, 2007 [sOLVED] SELECT *, COUNT(mode_ID) As Number FROM order_item,products WHERE products.prod_ID=order_item.mode_ID GROUP BY mode_ID ORDER BY Number DESC Thanks to http://www.webdevelopersnotes.com/tutorials/sql/online_mysql_training_course_counting.php3 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.