SQL的彙總統計SELECT語句

select Site,sum(case when type='item01' then 1 else 0 end) as item01, sum(case when type=item02' then 1 else 0 end) as item02, sum(case when type='item03' then 1 else 0 end) as item03,count(*) as SubTotal from Table  group by site

 

說明:

用於彙總統計各個SITE的ITEM01/02/03的數量

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章