select count(*) from (select distinct 列名 from 表名) a
用group by 例如
select count(id) from stu group by age
查学生表,按age分组,计算出id的数量 , 得出就是所有不同值年龄的数量