select all rows except top row

D-Dawgg picture D-Dawgg · Feb 22, 2013 · Viewed 22.7k times · Source

how do I return all rows from a table except the first row. Here is my sql statement:

Select Top(@TopWhat) * 
from tbl_SongsPlayed 
where Station = @Station 
order by DateTimePlayed DESC

How do I alter my SQL statement to return all rows except the first row.

Many thanks

Answer

chrisb picture chrisb · Feb 22, 2013

SQL 2012 also has the rather handy OFFSET clause:

Select Top(@TopWhat) *
from tbl_SongsPlayed 
where Station = @Station 
order by DateTimePlayed DESC
OFFSET 1 ROWS