webguync Posted June 22, 2009 Share Posted June 22, 2009 how would I write SQL to get a number count of the distinct data records in a table column? I tried this but get an error SELECT COUNT(*) DISTINCT territory_id from roster Quote Link to comment https://forums.phpfreaks.com/topic/163255-solved-counting-distinct-data-in-columns/ Share on other sites More sharing options...
Maq Posted June 22, 2009 Share Posted June 22, 2009 The correct syntax is: SELECT COUNT(DISTINCT territory_id) FROM roster It may be faster to use GROUP BY rather than DISTINCT. Quote Link to comment https://forums.phpfreaks.com/topic/163255-solved-counting-distinct-data-in-columns/#findComment-861378 Share on other sites More sharing options...
webguync Posted June 22, 2009 Author Share Posted June 22, 2009 cool, thanks Quote Link to comment https://forums.phpfreaks.com/topic/163255-solved-counting-distinct-data-in-columns/#findComment-861441 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.