Fork me on GitHub

青禹小生

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

导航

SQL Server2012关于表内事项出现次数降序排列(存储过程)

 1 USE [growup]
 2 GO
 3 SET ANSI_NULLS ON
 4 GO
 5 SET QUOTED_IDENTIFIER ON
 6 GO
 7 
 8 ALTER PROCEDURE  [dbo].[S_GetRankingList]
 9 @timestart datetime,
10 @timeend datetime
11 AS
12 BEGIN
13 
14     SET NOCOUNT ON;
15 
16     select *
17     from(
18     SELECT
19      count(1) as t,
20      S_BigClass as bc,
21      S_SmallClass as sc,
22      S_MatterName as mn from S_Matter
23      where 
24      @timestart<=S_PlanStart
25      and @timeend>=S_PlanStart
26      group by S_BigClass,S_SmallClass,S_MatterName
27      )as c
28      order by t desc
29 END

 

posted on 2015-11-19 23:19  司徒道  阅读(380)  评论(0编辑  收藏  举报