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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting the top n records 2

Status
Not open for further replies.

spuppett

Programmer
Jan 25, 2003
48
US
This is probably a very n00bish question, but I haven't been able to find much. Its hard to do a search on SQL top. I'm looking for a way to get only the first n records back from a SELECT statement. I've seen 'SELECT TOP(n) FROM tbl', but VFP says the statement is invaild, which leads me to believe that top is a vender function, rather then an SQL standard. Is there a way to do this, with out having a program that loops, ie
Code:
  SELECT * FROM tbl;
  for i = 0 to n
    do some stuff
  next

Thanks [hourglass]
 

Can you clarify? Are you querying an SQL table or a DBF table.

Code:
SELECT * top(1) FROM ALIAS() ORDER BY 1

Top requires an ORDER BY.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top