ashburnham Posted November 26, 2007 Share Posted November 26, 2007 Probably a simple one but I'm a bit of a novice so any help would be appreciated. Within my database I have a table called customer and a column within called refer. The refer column is populated by a single name such as Steve, Bob, Joe, Dave, Bob, Derek, Joe, Bob, etc... I want to run a query to get all occurrences of a name and the number of times it occurs and display it all in a nice little table but can't think how to do this ??? Desired outcome (using the above example) should be something like: Name |Occurrence Bob| 3 Joe| 2 Dave| 1 Derek| 1 Steve| 1 Any help would be appreciated - thanks... P.S. Being able to sort into name or occurrences order would be preferred but not vital. Quote Link to comment Share on other sites More sharing options...
fenway Posted November 26, 2007 Share Posted November 26, 2007 Try this: SELECT nameField, COUNT( nameField ) AS occurence FROM yourTable GROUP BY nameField ORDER BY occurence DESC 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.