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!

I know how to use a query to show m 1

Status
Not open for further replies.

NewToProgramming

Technical User
Jun 24, 2003
31
US
I know how to use a query to show me the maximum record, example:
Query.SQL.Add ('Select Max fieldname as whatever from database')
But how would you have the query give you the top 10 of the latest 20 results?
Thank you,
Mark
 
hi

If you're using SQLServer you can do it with

select top 10 max(field) from blah

With other databases you will probably have to restrict it programmatically, for example

i := 1
query.first;
while not query.eof and (i<=10) do
begin
memo.lines.add(query.fields[0].<asWhatever>)
query.next;
inc(i);
end;

lou

 
and what about the bottom 10 of 20 as well?
Sorry, should have asked both questions at the same time.
Mark
 
Never mind. I got it to go backwards too. Wasn't too hard to figure out.
Thank you,
Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top