日期:2014-05-18  浏览次数:20528 次

可以简化以下SQL语句吗?
select   [id],total=sum(totalfee),ordercount   =   count(billid)   from   v_billm    
where   year(datecreated)=year(@repdate)  
and   month(datecreated)=month(@repdate)  
and   day(datecreated)=day(@repdate)
and   isreject=0   group   by   [id]

上述语句中日期型数值的比较,能否简化一下啊?
我不能直接用datecreated   =   @repdate
是因为datecreated中含有时分秒,而repdate只含日期.
如果只比较日期部分相等的简单SQL语句啊?

------解决方案--------------------
select [id],total=sum(totalfee),ordercount = count(billid) from v_billm
where convert(char(10),datecreated,120)=convert(char(10),@repdate,120)
and isreject=0 group by [id]
------解决方案--------------------
where datediff(day,datecreated,@repdate)=0 and isreject=0