soycharliente Posted June 29, 2007 Share Posted June 29, 2007 What's the best/quickest way to count unique row entries? I have a table of data with one field being 'loc' and want to count each unique loc. So if I have: id loc 1 mexico 2 mexico 3 china 4 usa 5 usa I want to run a query and return something like: mexico 2 china 1 usa 2 Quote Link to comment Share on other sites More sharing options...
tippy_102 Posted June 29, 2007 Share Posted June 29, 2007 SELECT DISTICT loc, count(loc) AS loc_count FROM .... should do what you want. Quote Link to comment Share on other sites More sharing options...
teng84 Posted June 29, 2007 Share Posted June 29, 2007 SELECT country,count(distinct `country`) FROM `table` group by country that works 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.