亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

解析關(guān)于SQL語(yǔ)句Count的一點(diǎn)細(xì)節(jié)

 更新時(shí)間:2013年06月26日 17:21:21   作者:  
本篇文章是對(duì)關(guān)于SQL語(yǔ)句Count的一點(diǎn)細(xì)節(jié)進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
 count語(yǔ)句支持*、列名、常量、變量,并且可以用distinct關(guān)鍵字修飾, 并且count(列名)不會(huì)累計(jì)null的記錄。下面隨便用一些例子示范一下count的規(guī)則:比如對(duì)如下表做統(tǒng)計(jì),所有列這里都用sql_variant類型來(lái)表示。

復(fù)制代碼 代碼如下:

if (object_id ('t_test' )> 0 )
    drop table t_test
go
create table t_test (a sql_variant , b sql_variant , c sql_variant )
insert into t_test select 1 , 1 , 'a'
insert into t_test select 1 , getdate (), null
insert into t_test select 'a' , null , 1
insert into t_test select 3 , null , null
insert into t_test select null , null , null
go
select * from t_test
go
select
     count (* )                --總數(shù)
    , count (nullif (1 , 1 ))        --永遠(yuǎn)返回0
    , count (a )                --a數(shù)量
    , count (b)                --b數(shù)量
    , count (distinct a )        --a不重復(fù)數(shù)量
    , count (isnull (b, c ))        --b或者c不為null數(shù)量
    , count (Coalesce (a , b, c ))    --a或者b或者c不為null數(shù)量
    , count (nullif (a , b))        --a不等于b的數(shù)量
    , count (nullif (isnumeric (cast (a as varchar (38 ))), 0 ))--a是數(shù)字的數(shù)量
from t_test

相關(guān)文章

  • sql 服務(wù)器知識(shí)

    sql 服務(wù)器知識(shí)

    服務(wù)器組只是個(gè)邏輯上的概念,類似于班級(jí)或者QQ里面的同事、朋友、家人的分組。一般班級(jí)下面有N個(gè)學(xué)生。學(xué)生就相當(dāng)于服務(wù)器了。
    2009-10-10
  • 最新評(píng)論