日期:2014-05-18 浏览次数:20529 次
select SUM(price) as sumpayD from pay where DATEPART(MM,time) =DATEPART(MM,GETDATE()) and DATEPART(YY,time) =DATEPART(YY,GETDATE()) and userid=1 group by cast(time as varchar(10))
------解决方案--------------------
select convert(varchar(10),time,120) D,SUM(price) as sumpayD from pay where DATEPART(MM,time) =DATEPART(MM,GETDATE()) and DATEPART(YY,time) =DATEPART(YY,GETDATE()) and userid=1 group by convert(varchar(10),time,120)
------解决方案--------------------
select convert(varchar(10),time,120),d,sum(price) as sumpayD from pay where datediff(mm,time,getdate())=0 and userid=1 group by convert(varchar(10),time,120),d
------解决方案--------------------
select SUM(price) as sumpayM from pay where DATEPART(MM,time) =DATEPART(MM,GETDATE()) and DATEPART(YY,time) =DATEPART(YY,GETDATE()) and userid=1 group by convert(varchar(10),time,120)
------解决方案--------------------
--多分析一下问题,往往分析能帮你发现新的思路
select
convert(varchar(10),time,120),d,sum(price) as sumpayD
from
pay
where
datediff(mm,time,getdate())=0
and
userid=1
group by
convert(varchar(10),time,120),d