是这个意思吗
select datepart(mm,时间),count(*) from 表 group by datepart(mm,时间)

解决方案 »

  1.   

    我的意思是where条件中,时间要做成变量,原表中时间为yy:m:d H:mm:ss,现在的问题是各月天数不一样,比如6月为:
    datediff ([month] ,InputDateTime,'2005-6-30')=0 
    7月为:
    datediff ([month] ,InputDateTime,'2005-7-31')=0 
    怎么样从能把'2005-7-31'这一部分做成一个变量
    让查询的时候可以选择按月份查询
      

  2.   

    rpv 按月份比较就行了,不用管他到底几天的。
      

  3.   

    6月:
    select * from 表 where month(时间字段)=67月;
    select * from 表 where month(时间字段)=7
      

  4.   

    --agree vivianfdlpw() 
    用month函数