选择除第一个表外的表行

时间:2011-05-17 06:35:25

标签: sql sql-server tsql sql-server-2008

我想选择除Top One之外的所有行,所以任何人都可以帮我解决这个问题。

3 个答案:

答案 0 :(得分:9)

with cte as
(
    select *, row_number() over (order by CustomerId) RowNumber
    from Sales.Customer
)
select *
from cte
where RowNumber != 1

OR

select *
from
(
    select *, row_number() over (order by CustomerId) RowNumber
    from Sales.Customer
) tt
where RowNumber != 1

答案 1 :(得分:1)

SELECT * FROM table1
EXCEPT SELECT TOP 1 * FROM table1

答案 2 :(得分:0)

在SQL Server 2012中,您可以执行以下操作:

select * from TableName order by Id offset 1 rows