Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select Top 40 Records 2

Status
Not open for further replies.

RoguePoet01

Programmer
Oct 1, 2003
302
US
Hi,

Is there a way to select only 40 of the "Top" or "most recent" records in a query?

Thanks.
 
As STO says, use the TOP 40 in your SELECT, but you also need an ORDER BY to show how the TOP 40 is to be selected.

example:
Code:
SELECT TOP 40 mydate,
              myname
FROM mydatabase
ORDER BY mydate ASC
That will return the TOP 40 earliest records.
Using ORDER BY mydate DESC will return the 40 latest (most recent) records.

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top