Guest Posted May 27, 2007 Share Posted May 27, 2007 I want to find the most occurring rows in a table. Lets say i want to find the most with the column Owner_ID how can i find this out? Quote Link to comment https://forums.phpfreaks.com/topic/53140-most-occurring/ Share on other sites More sharing options...
Barand Posted May 27, 2007 Share Posted May 27, 2007 SELECT Owner_ID, COUNT(*) as total FROM tablename GROUP BY Owner_ID ORDER BY total DESC LIMIT 1 Quote Link to comment https://forums.phpfreaks.com/topic/53140-most-occurring/#findComment-262522 Share on other sites More sharing options...
Guest Posted May 27, 2007 Share Posted May 27, 2007 Thank You thanks what I needed. Quote Link to comment https://forums.phpfreaks.com/topic/53140-most-occurring/#findComment-262526 Share on other sites More sharing options...
bubblegum.anarchy Posted May 27, 2007 Share Posted May 27, 2007 SELECT Owner_ID, COUNT(*) as total FROM tablename GROUP BY Owner_ID ORDER BY total DESC LIMIT 1 What about situations that involve more that one grouped record containing the highest total count? Quote Link to comment https://forums.phpfreaks.com/topic/53140-most-occurring/#findComment-262610 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.