Mar 15, 2004 #1 RoguePoet01 Programmer Joined Oct 1, 2003 Messages 302 Location US Hi, Is there a way to select only 40 of the "Top" or "most recent" records in a query? Thanks.
Mar 15, 2004 1 #2 sto Programmer Joined Nov 26, 2001 Messages 14 Location US Add this to your syntax SELECT TOP 40 Upvote 0 Downvote
Mar 15, 2004 1 #3 SQLBill MIS Joined May 29, 2001 Messages 7,777 Location US 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 Upvote 0 Downvote
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
Mar 15, 2004 Thread starter #4 RoguePoet01 Programmer Joined Oct 1, 2003 Messages 302 Location US My thanks to both of you. Upvote 0 Downvote