Luigi Talamo
asked on
query select top n records
Greetings!
in my betting software project i have 2 tables and a query like this:
procedure TMain.Button16Click(Sender : TObject);
begin
ADOTABLE2.first;
while NOT ADOTABLE2.EOF do BEGIN
ADOQuery8.Close;
ADOQuery8.SQL.Clear;
ADOQuery8.SQL.Add ('SELECT SUM(W1) as total1, SUM(B1) as total2, COUNT(*) AS TOT');
ADOQuery8.SQL.Add ('FROM Table1');
ADOQuery8.SQL.Add ('WHERE League = '+QUOTEDSTR(adotable2.Fiel dByName('L eague').as string));
ADOQuery8.Open;
It works very well, but i need to get only the first 30 records from table1 and not the whole records.
The table also has a date field called 'data', i made many tests but with no success...
It is a delphi app (embarcadero xe8) with ado components and ms access tables.
Thanks!
Luigi
in my betting software project i have 2 tables and a query like this:
procedure TMain.Button16Click(Sender
begin
ADOTABLE2.first;
while NOT ADOTABLE2.EOF do BEGIN
ADOQuery8.Close;
ADOQuery8.SQL.Clear;
ADOQuery8.SQL.Add ('SELECT SUM(W1) as total1, SUM(B1) as total2, COUNT(*) AS TOT');
ADOQuery8.SQL.Add ('FROM Table1');
ADOQuery8.SQL.Add ('WHERE League = '+QUOTEDSTR(adotable2.Fiel
ADOQuery8.Open;
It works very well, but i need to get only the first 30 records from table1 and not the whole records.
The table also has a date field called 'data', i made many tests but with no success...
It is a delphi app (embarcadero xe8) with ado components and ms access tables.
Thanks!
Luigi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks alot!
ASKER
ADOQuery8.Close;
ADOQuery8.SQL.Clear;
ADOQuery8.SQL.Add ('SELECT SUM(W1) as totale1, SUM(B1)as totale2, COUNT(*) AS TOTA');
ADOQuery8.SQL.Add ('FROM (Select Top 30 * From Table1 WHERE League = '+QUOTEDSTR(adotable2.Fiel
ADOQuery8.Open;