Ver Mensaje Individual
  #2  
Antiguo 21-02-2012
Avatar de olbeup
olbeup olbeup is offline
Miembro
 
Registrado: jul 2005
Ubicación: Santiago de la Ribera (España)
Posts: 688
Reputación: 21
olbeup Va camino a la fama
Hola gianfranco_tont

Lo puedes hacer de dos formas.

Cita:
1.) Registro a registro
Código Delphi [-]
...
var
  ImporteTotal: Extended;
begin
  with adoquery do
    while (not eof) do
    begin
      ImporteTotal := ImporteTotal + FieldByName('TOTAL').AsFloat;

      Edit1.Text := FormatFloat('#,#0.00', ImporteTotal);

      Next;
    end;
end;
Cita:
2.) Por SQL
Código Delphi [-]
...
var
  ImporteTotal: Extended;
begin
  with adoQry do
  begin
    SQL.Clear;

    SQL.Add('SELECT');
    SQL.Add('    SUM(TOTAL) AS IMPORTETOTAL');
    SQL.Add('  FROM Pedido');
    SQL.Add('  WHERE IDPEDIDO = 45');

    Open;

    ImporteTotal := FieldByName('IMPORTETOTAL').AsFloat;

    Edit1.Text := FormatFloat('#,#0.00', ImporteTotal);

    Close;
  end;
end;

Espero que te sirva o te oriente.

Un saludo.
__________________
Al hacer una consulta SQL, haz que los demás te entiendan y disfruten de ella, será tú reflejo de tú saber.
Responder Con Cita