SQLÈ¡³öµÚ m Ìõµ½µÚ n Ìõ¼Ç¼µÄ·½·¨
´ÓTable ±íÖÐÈ¡³öµÚ m Ìõµ½µÚ n ÌõµÄ¼Ç¼£º(Not In °æ±¾)
SELECT TOP n-m+1 *
from Table
WHERE (id NOT IN (SELECT TOP m-1 id from Table ))
--´ÓTABLE±íÖÐÈ¡³öµÚmµ½nÌõ¼Ç¼ (Exists°æ±¾)
SELECT TOP n-m+1 * from TABLE AS a WHERE Not Exists
(Select * from (Select Top m-1 * from TABLE order by id) b Where b.id=a.id )
Order by id
--mΪÉϱ꣬nΪϱê,ÀýÈçÈ¡³öµÚ8µ½12Ìõ¼Ç¼,m=8,n=12,TableΪ±íÃû
Select Top n-m+1 * from Table
Where Id>(Select Max(Id) from
(Select Top m-1 Id from Table Order By Id Asc) Temp)
Order By Id Asc
1. Select Top n-m+1 * from Table Where Id>(Select Top m-1 Id from Table Order By Id Asc) Order By Id Asc
2. SQL Server 2005 ÖпÉÒÔÓà ROW_NUMBER£¨£© OVER£¨£©ÅäºÏÈ¡·ÖÒ³Êý¾ÝÁË¡£
DECLARE @StartRow INT
DECLARE @PageSize INT
SET ROWCOUNT 0
SET @StartRow = 100
SET @PageSize = 10
SELECT * from
(
SELECT ROW_NUMBER() OVER (ORDER BY Name) AS RowNumber,* from Person
) AS A WHERE A.RowNumber BETWEEN @StartRow + 1 AND @StartRow + @PageSize
3. select top n-m+1 from A where id not in (select m-1 id from A)
Ïà¹ØÎĵµ£º
¿´¿´ÒÔÏÂSQLÓï¾ä£º
select row_number() over(partition by xs.xsbh, xs.kch order by coalesce(xs.bkxnxqh, xs.xnxqh) desc) rn
row_number()£º´ú±íÁÐ
partition by ´ú±í°´Ê²Ã´½øÐзÖ×é
order by¶Ôÿһ×éÐÅÏ¢½øÐÐÅÅÐò
coalesce()ÊÇÌæ»»µÄÒâ˼ ÀýÈ磺ÉÏÃæµÄSQLÓï¾äµÄÒâ˼ÊÇ£¬Èç¹ûbkxnxqhΪ¿Õ£¬ÄÇô¾ÍÈ¥xnx ......
Êý¾Ý¿âʵÀý½á¹¹ ÊÂÎñÒ»ÖÂÐÔ(Transactional Consistency)ºÍ»ùÓÚʱ¼äµãµÄ»Ö¸´(Point-in-time Recovery) ϵͳԪÊý¾Ý
topÊý¾Ý¿âʵÀý½á¹¹
µ±OracleʵÀýÆô¶¯Ö®ºó£¬Ëù¿´µ½µÄ¾ÍÊÇÔÚ·þÎñÆ÷ÄÚ´æÉϵÄÒ»¸ö¸ö²»Í¬ÄÚ´æ¿é¼ÓÉϲúÉúµÄÓëÕâЩÄÚ´æ½»»¥µÄºǫ́½ø³Ì¡£OracleÎĵµ½«ÕâЩÄÚ´æ½á¹¹ºÍ½ø³ÌÊյĺÜÏêϸ¡£
ÓÉOracleʵÀýËùÕ¼ÓõÄÄÚ´æ¿é³ ......
Ò» ϵͳԤ¶¨Òå´íÎó´úÂë
SQL Server ÓÐ3831¸öÔ¤¶¨Òå´íÎó´úÂ룬ÓÉmaster.dbo.sysmessages±íά»¤¡£Ã¿Ò»¸ö´íÎó´úÂë¶¼ÓÐÏàÓ¦µÄ¼¶±ðºÍÃèÊö¡£
´íÎó¶¨ÒåµÄ¼¶±ð´Ó0µ½25¡£20ÒÔÉϵĴíÎó´ú±íÖØ´ó´íÎó£¬Í¨³£ÒâζןôíÎó»áµ¼Ö´洢½ø³ÌÁ¢¿ÌÖÕÖ¹£¬²¢ÇÒËùÓеĿͻ§Á¬½Ó¶¼ÒªÖØÐ³õʼ»¯¡£
·Ç¹Ø¼üÐÔ´íÎóÖ»ÊǽûÖ¹µôµ±Ç°ÔËÐеijÌÐòÐУ¬²¢¼Ì ......
select ks.login_name,ks.exam_name,ks.start_time,ks.end_time,cj.score
from (
select u.user_id,u.login_name,e.* from cphrms.EXAM_USER eu, cphrms.users u, cphrms.exam_info e
where eu.user_id = u.user_id and eu.exam_id = e.exam_id
) ks
left ......