rmpotter Posted August 7, 2009 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 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
Archived
This topic is now archived and is closed to further replies.