selecting the Row of table Except the First one

2019-02-08 08:45发布

问题:

i want to select all the row except the Top One so can anybody help me on this Query.

回答1:

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


回答2:

SELECT * FROM table1
EXCEPT SELECT TOP 1 * FROM table1


回答3:

In SQL Server 2012, you can do this:

select * from TableName order by Id offset 1 rows