SQL Help

Wee

Wee

Associate
Joined
25 Apr 2006
Posts
130
Location
Scotland
Working on some web stuff at the moment, and have come across a problem. I have a table in my database that is choco-block full of rows, but only want to display the 5 latest entries instead of them all. I was wondering it there is an SQL statement that is able to only output a specific number of rows?
 
Soldato
Joined
18 Oct 2002
Posts
5,600
Location
Surrey
yes.

How are they indexed? if they are by a incrementing key number then order by that and get the last 5 records.

what columns are in the table and what database engine is it?
 

Wee

Wee

Associate
OP
Joined
25 Apr 2006
Posts
130
Location
Scotland
The database is SQL Server 2005.

They won't be indexed by an incremented key number, most likely will be done by date.
 
Associate
Joined
3 Oct 2006
Posts
2,304
Location
London
.....But yeah use his. It is more 'correct' than mine (even though both will work). I don't have a MSSQL server to test it on at home though!
 
Back
Top Bottom