22,209
社区成员
发帖
与我相关
我的任务
分享
select * from DingDan where TaoXi_ID=100003 and datediff(yy,D_Time1,getdate()) = 0
create proc DingDan_GetTaoXiCount
@ShopID int,TaoXiID int
as
begin
select m.month , isnull(n.TaoXi_ID,0) TaoXi_ID from
(
select 1 month union
select 2 month union
select 3 month union
select 4 month union
select 5 month union
select 6 month union
select 7 month union
select 8 month union
select 9 month union
select 10 month union
select 11 month union
select 12 month
) m
left join
(select datepart(mm,D_Time1) D_Time1 , count(TaoXi_ID) TaoXi_ID from DingDan where TaoXi_ID=100003 and datediff(yy,D_Time1,getdate()) = 0 group by datepart(mm,D_Time1)) n
on m.month = n.D_Time1
end
go