select distinct id from table1;
结果如下,注意有1个空的值,
id==========
12
3
4
5
========
但执行
select cout(distinct id) from table1;
结果却是 5 ,这怎么查 ? oracle数据库

解决方案 »

  1.   

    有什么办法计算出来吗,
    全表:
      id ,value   1    100
      1    200
           300
      2    400
      3    600
      4    700
      5    800需要出count id结果  5条记录,
    就是计算不同的id个数,包括空值
      

  2.   

    想要6呗?
    select cout(distinct nvl(id,0)) from table1; 
      

  3.   

    select count(distinct(nvl(id,'fuck_oracle'))) from test;
      

  4.   

    select count(distinct id || ' ') from table1;