- 在count 不重复的记录的时候能用到,eg:
SELECT COUNT( DISTINCT description) FROM tablename;
- 在需要返回记录不同的description的具体值的时候可以用,eg:
SELECT DISTINCT FROM tableName
- 另一种写法
SELECT id, description, COUNT( DISTINCT id) as c
FROM tablename
GROUP BY description
这样返回的结果中就会出现多余的无用数据,可以得到结果集后在过滤没用的数据
写的不错