2

我想从 SQL Server 2005 Express 数据库中排除显示的第一行...我该怎么做?

我知道如何只返回第一行,但是如何返回除第一行之外的所有行

4

4 回答 4

5
SELECT *
FROM yourTable 
WHERE id NOT IN (
         SELECT TOP 1 id 
         FROM yourTable 
         ORDER BY yourOrderColumn)
于 2011-08-10T19:52:51.960 回答
2
SELECT *
    FROM SomeTable
    WHERE id <> (SELECT MIN(id) FROM SomeTable)
    ORDER BY id
于 2011-08-10T19:53:06.887 回答
2
select * from 
    (select ROW_NUMBER() over (order by productid) as RowNum, * from products) as A
where A.RowNum > 1
于 2011-08-10T19:53:50.693 回答
1

当你说你不想要第一行时,我假设你有某种order by定义哪一行在顶部。此示例使用该ID列来执行此操作。

declare @T table(ID int, Col1 varchar(10))

insert into @T
select 1, 'Row 1' union all
select 2, 'Row 2' union all
select 3, 'Row 3'

select ID
from @T
where ID <> (select min(ID)
             from @T)
order by ID
于 2011-08-10T19:57:58.837 回答