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
SQL Server2012关于表内事项出现次数降序排列(存储过程)
原文:http://www.cnblogs.com/laresh/p/4979426.html