Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 选择第8行后的前3行_Sql Server_Sql Server 2008 - Fatal编程技术网

Sql server 选择第8行后的前3行

Sql server 选择第8行后的前3行,sql-server,sql-server-2008,Sql Server,Sql Server 2008,我有一个表:id、组、状态、主题 我需要group=2和status=2的行,但我想跳过按id排序的前8个结果。这是我尝试的,但它不会跳过前8行: SELECT TOP 3 [id], LEFT ([subject],30) AS Title FROM [Katavot] WHERE (([Status] = @Status) AND ([Group] = @Group)) ORDER BY [id] DESC 看起来很像 看起来非常类似。基于 基于 MySQL: MSSQL:

我有一个表:id、组、状态、主题

我需要group=2和status=2的行,但我想跳过按id排序的前8个结果。这是我尝试的,但它不会跳过前8行:

SELECT TOP 3 [id], LEFT ([subject],30) AS Title 
FROM [Katavot] 
    WHERE (([Status] = @Status) AND ([Group] = @Group)) 
ORDER BY [id] DESC
看起来很像

看起来非常类似。

基于

基于

MySQL:

MSSQL:

select top y *
from <table>
where <unique id> not in (select top x <unique id> from <table> order by <unique id>)
from <table> order by <unique id>
MySQL:

MSSQL:

select top y *
from <table>
where <unique id> not in (select top x <unique id> from <table> order by <unique id>)
from <table> order by <unique id>
LIMIT x, y
select top y *
from <table>
where <unique id> not in (select top x <unique id> from <table> order by <unique id>)
from <table> order by <unique id>