How to exclude first row in SQL Server 2005 Expres

2019-07-21 05:55发布

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

4条回答
Rolldiameter
2楼-- · 2019-07-21 06:34
SELECT *
    FROM SomeTable
    WHERE id <> (SELECT MIN(id) FROM SomeTable)
    ORDER BY id
查看更多
3楼-- · 2019-07-21 06:35

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
查看更多
霸刀☆藐视天下
4楼-- · 2019-07-21 06:39
SELECT *
FROM yourTable 
WHERE id NOT IN (
         SELECT TOP 1 id 
         FROM yourTable 
         ORDER BY yourOrderColumn)
查看更多
姐就是有狂的资本
5楼-- · 2019-07-21 06:52
select * from 
    (select ROW_NUMBER() over (order by productid) as RowNum, * from products) as A
where A.RowNum > 1
查看更多
登录 后发表回答