sql统计不重复条数

select count(distinct 字段) from 表;

--------------------------

结果:185692条

select count(1) from(select distinct 字段 from 表)

结果:185693条

为什么结果不一样?
另外,还有没有其它的统计方法(不用distinct).

第1个回答  2009-12-13
select count(*)
from
(
select 字段
from 表
group by 字段
having count(字段)<=1
order by 字段
)
结果应该和
select count(1) from(select distinct 字段 from 表)一样
这种方法才是对的本回答被提问者和网友采纳
相似回答