2

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Denis
  • 21
  • 1
  • 2

4 Answers4

5
SELECT *
FROM yourTable 
WHERE id NOT IN (
         SELECT TOP 1 id 
         FROM yourTable 
         ORDER BY yourOrderColumn)
Jacob
  • 41,721
  • 6
  • 79
  • 81
2
SELECT *
    FROM SomeTable
    WHERE id <> (SELECT MIN(id) FROM SomeTable)
    ORDER BY id
Joe Stefanelli
  • 132,803
  • 19
  • 237
  • 235
2
select * from 
    (select ROW_NUMBER() over (order by productid) as RowNum, * from products) as A
where A.RowNum > 1
Brian Webster
  • 30,033
  • 48
  • 152
  • 225
1

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
Mikael Eriksson
  • 136,425
  • 22
  • 210
  • 281