myflashstore Posted March 14, 2010 Share Posted March 14, 2010 Hi, I'm trying to select the top 10 selling customers. I have 2 tables involves, a user table jos_users and an items table jos_mfs_items. This is the sql i'm using but it's not returning any results, i'm not sure if I am doing it right, can someone help? SELECT jos_users.*, COUNT(jos_mfs_items.*) FROM jos_users INNER JOIN jos_mfs_items ON jos_users.id = jos_mfs_items.producer WHERE jos_mfs_items.order_status = 1 GROUP BY jos_users.id ORDER BY COUNT(jos_mfs_items.*) DESC LIMIT 10 Quote Link to comment https://forums.phpfreaks.com/topic/195185-query-help-for-selecting-top-selling-customers/ Share on other sites More sharing options...
fenway Posted March 19, 2010 Share Posted March 19, 2010 Re-write the query without the group by, and see if you're addressing the correct recordset. Quote Link to comment https://forums.phpfreaks.com/topic/195185-query-help-for-selecting-top-selling-customers/#findComment-1028542 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.