select sum(金额)
from tablename
where datediff(month,getdate(),日期)=0

解决方案 »

  1.   

    select sum(money)
    from table
    where year(datetime)=year(taday()) and 
           month(datetime)=month(taday())
    group by datetime
      

  2.   

    select sum(money) as je where month(datetime)=所要的月份
      

  3.   

    select sum(金额) as 本月
    from tablename
    where datediff(month,getdate(),字段日期)=0 
    select sum(金额) as 本年
    from tablename
    where datediff(year,getdate(),字段日期)=0
      

  4.   

    select sum(money) form where month(datetime)=month(getdate())
      

  5.   

    落了点东西select sum(money) as je from 表名 where month(datetime)=所要的月份
      

  6.   

    select sum(money)  as 本月 from tablename where month(datetime)=month(getdate())//本月的
    select sum(money) as 本年  from  tablename where year(datetime)=year(getdate())//本年的
      

  7.   

    参考一下吧:select sum(money) from 表格 where datetime between (dateadd(d,-datepart(d,getdate()),getdate()),gettime())
      

  8.   

    最笨的方法是通过convert把dcatetime转变成varchar.
    在sum(money)也可以select sum(money) from ## where datepart(year,datetime)=datepart(year,getdate()) and datepart(month,datetime)=datepart(month,getdate())