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