Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

selecting the Row of table Except the First one

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

like image 397
Dinup Kandel Avatar asked May 17 '11 06:05

Dinup Kandel


People also ask

How do I SELECT all rows to except the first row in SQL?

The SQL EXCEPT operator is used to return all rows in the first SELECT statement that are not returned by the second SELECT statement. Each SELECT statement will define a dataset. The EXCEPT operator will retrieve all records from the first dataset and then remove from the results all records from the second dataset.

How do I SELECT a specific row in a table in SQL?

To select rows using selection symbols for character or graphic data, use the LIKE keyword in a WHERE clause, and the underscore and percent sign as selection symbols. You can create multiple row conditions, and use the AND, OR, or IN keywords to connect the conditions.

How do I SELECT only the first row?

To return only the first row that matches your SELECT query, you need to add the LIMIT clause to your SELECT statement. The LIMIT clause is used to control the number of rows returned by your query. When you add LIMIT 1 to the SELECT statement, then only one row will be returned.


1 Answers

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
like image 50
Alex Aza Avatar answered Oct 02 '22 23:10

Alex Aza