rmpotter Posted August 7, 2009 Report Share Posted August 7, 2009 I am trying to display an SQL table where-in I have a field entitled 'categories'. Lets say I have 5 entries entitles 'cars', 3 entilted trucks and 6 entitled 'Buses'I am looking to sort this data out by category and have the category occurring most (buses) list it's info first and then list each other category by number of occurrences thereafter. Can anyone help? Link to comment Share on other sites More sharing options...
justsomeguy Posted August 7, 2009 Report Share Posted August 7, 2009 SELECT category, COUNT(category) AS num FROM table GROUP BY category ORDER BY num DESC Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now