您现在的位置: 万盛学电脑网 >> 程序编程 >> 数据库 >> mssql数据库 >> 正文

SqlServer统计表中某年某月某个值有多少?

作者:佚名    责任编辑:admin    更新时间:2022-06-22

   比如:统计表AA中YWLX列在某年某月每种类型各有多少?
?

1 2 3 4 5 6 select year(AA_YWRQ) as YEARS,   month(AA_YWRQ) AS Months ,AA_YWLX,count(AA_YWLX) as Number from  AA group by year(AA_YWRQ),   month(AA_YWRQ),AA_YWLX

  表中数据:

SqlServer统计表中某年某月某个值有多少?   三联

  查询后的结果: