Results 1 to 2 of 2
Thread: Display first X rows with SQL
Nov 8, 2001, 18:51 #1
- Join Date
- Feb 2000
- Brisbane, Queensland, Australia
- 0 Post(s)
- 0 Thread(s)
Display first X rows with SQL
Hi, I am having a problem with an SQL query and a friend has a book of mine I know has the answer. So I decided to ask here instead.
I am using JSP with an Access database and need to make an SQL query which returns the first four results in a resultset.
I know I could just get all the results, and only take the first four results from the set, but I figured it is more efficient if I use an SQL query which only returns the first four results.
The query which returns everything is
ORDER BY FieldName desc;
Would be great if someone could help me with the count function or whatever to only return the first four results from the above query.
SQL Server 2005 Books
www.SQLServer2005Books.com - Reader-rated SQL Server 2005 Books
Nov 8, 2001, 18:56 #2
Try something like this:
SELECT TOP 4 tableItem
ORDER by tblItem desc
Hope that helps