日期:2014-05-18  浏览次数:20469 次

超级简单的问题,但是我就是不懂,我菜啊~~~~~~~~~~~~~~~~
是关于存储过程的问题,很简单的,但是偶就是不懂
CREATE   PROCEDURE   GetApplyGaoZhao
AS
SELECT   TOP   10*   ,
GaoZhaoId,
GaoZhaoName
FROM   GaoZhaoInfo
where
Active=1   OR   Active=2  
ORDER   BY   ApplyDate   DESC
GO
========================
类似上面的存储过程,我该怎么改才能实现这样的功能?即从排序的数据中,获取排除头N条的前M条数据呢?比如:
以下是ORDER   BY   ApplyDate   DESC
序号 数据
1  a
2           b
3           c
4           d
5           k
6           s
7           y
8           t
9           h
==============
我要获得从第3位以下的前4位,即c   d   k   s

请问怎么实现,应该很简单,但是我就是不懂
郁闷啊~~~~~~~~~~




------解决方案--------------------
CREATE PROCEDURE GetApplyGaoZhao
AS
SELECT TOP 4 GaoZhaoId,GaoZhaoName
FROM GaoZhaoInfo
where GaoZhaoId not in(select top 2 GaoZhaoId from GaoZhaoInfo where id Active=1 OR Active=2
ORDER BY ApplyDate DESC)
and Active=1 OR Active=2
ORDER BY ApplyDate DESC
GO