周查询

create proc GetUserCount(

    @Type int,       --1按周统计,为其它按月统计

    @SDate int,

    @EDate int

)as

if @Type=1

begin

    select datename(week,logdate) as weeks,COUNT(*) as usercount 

    from (select distinct logdate,number from Log_PlayTime) 

    where datename(week,logdate) between @SDate and @EDate 

    group by datename(week,logdate)

end

else 

begin

    select datename(month,logdate) as months,COUNT(*) as usercount 

    from (select distinct logdate,number from Log_PlayTime) 

    where datename(month,logdate) between @SDate and @EDate 

    group by datename(month,logdate)

    having COUNT(*)>3

end

return

go

<!--EndFragment-->
发布了173 篇原创文章 · 获赞 4 · 访问量 5万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章