count(*)与count(column_name)的区别

count(*)===>表的记录数,与某个字段是否为空无关
count(column_name)===>如果当前列有空,则会剔除掉该列为空的那些行

可以参看以下实验结果:
SQL> select count(*) from table_name t where t.lvx_id is null;

COUNT(*)
----------
         9

SQL> select count(t.lvx_id) from table_name t where t.lvx_id is null;

COUNT(T.LVX_ID)
---------------
              0

SQL>

【编写于 2009-01-20】

猜你喜欢

转载自can-do.iteye.com/blog/2293234