Teck Posted September 16, 2007 Share Posted September 16, 2007 Alright, Maybe thats not the best title but its the best i can think of... Alright, Heres the deal, I want to count the number of times each user-name appears in one of my tables and then multiply the number of occurrences by a number... I'm really not even sure how I should do this at this point... Or even if this would be the best way to do it so any input or suggestions would be greatly appreciated... Link to comment https://forums.phpfreaks.com/topic/69582-solved-count-the-number-of-times-each-username-appears-in-a-table/ Share on other sites More sharing options...
roopurt18 Posted September 16, 2007 Share Posted September 16, 2007 Or even if this would be the best way to do it Do what? Here's a query that will do this for you: SELECT username, COUNT( DISTINCT username ) * someNumber AS `occurs` FROM your_table GROUP BY username ORDER BY username Link to comment https://forums.phpfreaks.com/topic/69582-solved-count-the-number-of-times-each-username-appears-in-a-table/#findComment-349673 Share on other sites More sharing options...
Barand Posted September 16, 2007 Share Posted September 16, 2007 Hmm, If you have a group where all records contain "Roopert" then COUNT(DISTINCT username) will give 1 for the group. Just use COUNT(*) Link to comment https://forums.phpfreaks.com/topic/69582-solved-count-the-number-of-times-each-username-appears-in-a-table/#findComment-349704 Share on other sites More sharing options...
Teck Posted September 16, 2007 Author Share Posted September 16, 2007 Between both of your posts I was able to get it all working... Thanks! Link to comment https://forums.phpfreaks.com/topic/69582-solved-count-the-number-of-times-each-username-appears-in-a-table/#findComment-349770 Share on other sites More sharing options...
roopurt18 Posted September 17, 2007 Share Posted September 17, 2007 Oh yes, right. Right. I may have been under the influence when I posted that! Link to comment https://forums.phpfreaks.com/topic/69582-solved-count-the-number-of-times-each-username-appears-in-a-table/#findComment-349923 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.