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... Quote Link to comment 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 Quote Link to comment 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(*) Quote Link to comment 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! Quote Link to comment 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! 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.