Fork me on GitHub

青禹小生

雁驰万里却作禽,鱼未得水空有鳞。 花开花落花不语,昨是昨非昨亦今。

导航

根据表内分数降序排列,显示用户名,大类,小类

 1 SET ANSI_NULLS ON
 2 GO
 3 SET QUOTED_IDENTIFIER ON
 4 GO
 5 
 6 CREATE PROCEDURE S_GetScoreRank
 7 @timestart datetime,
 8 @timeend datetime
 9 AS
10 BEGIN
11 select *
12     from(
13     SELECT
14      S_UserNum as u,
15      SUM (S_Score) as s,
16      S_BigClass as bc,
17      S_SmallClass as sc from S_Matter
18      where 
19      @timestart<=S_PlanStart
20      and @timeend>=S_PlanStart
21      group by S_UserNum,S_BigClass,S_SmallClass
22      )as c
23      order by s desc
24 END
25 GO

 若要按本月的发生的事件进行查询时可以 使用

Where DateDiff(mm,[Create on], GetDate()) = 0

上个月1 下个月-1

其他时间同上

posted on 2015-11-24 14:44  司徒道  阅读(326)  评论(0编辑  收藏  举报