问题
I want to exclude the first row from displaying from a SQL Server 2005 Express database... how do I do this?
I know how to return just the top row, but how do I return all rows, except the top row
回答1:
SELECT *
FROM yourTable
WHERE id NOT IN (
SELECT TOP 1 id
FROM yourTable
ORDER BY yourOrderColumn)
回答2:
SELECT *
FROM SomeTable
WHERE id <> (SELECT MIN(id) FROM SomeTable)
ORDER BY id
回答3:
select * from
(select ROW_NUMBER() over (order by productid) as RowNum, * from products) as A
where A.RowNum > 1
回答4:
When you say you don't want the top row I assume you have some kind of order by
that defines which row is at the top. This sample uses the ID
column to do that.
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
来源:https://stackoverflow.com/questions/7016863/how-to-exclude-first-row-in-sql-server-2005-express