count语句支持*、列名、常量、变量,并且可以用distinct关键字修饰, 并且count(列名)不会累计null的记录。下面随便用一些例子示范一下count的规则:比如对如下表做统计,所有列这里都用sql_variant类型来表示。
if (
object_id (
't_test' )
>
0 )
drop table t_test
go
create table t_test ( a sql_variant , b
drop table t_test
go
create table t_test ( a sql_variant , b