Board index » delphi » SQl Functions (sum, count)?

SQl Functions (sum, count)?

How do I get the value back from a sql function?

The following sql is excute, now how do I get at the value?

  DEDataModule.DEManaQry.Close;
  DEDataModule.DEManaQry.SQL.Clear;
  DEDataModule.DEManaQry.SQL.Add('Select Sum(MITR_AMOUNT) From MSTRAN
mstran');
  DEDataModule.DEManaQry.SQL.Add('Where (MITR_CODE = ' + '''' + 'FRV' + ''''
+ ')');
  DEDataModule.DEManaQry.SQL.Add('AND (MITR_DATE = TO_DATE(' + '''' +
     '05/03/2002' + '''' + ',' + '''' + 'mm/dd/yyyy' + '''' + '))');
  DEDataModule.DEManaQry.Open;

Thanks

 

Re:SQl Functions (sum, count)?


Bob

Quote
> The following sql is excute, now how do I get at the value?

Give the aggregate column a name, e.g.

Select Sum(MITR_AMOUNT) AS sum_mitr_amount From MSTRAN

Then,

DEDataModule.DEManaQry.FieldByName('sum_mitr_amount').AsFloat (or whatever).

--
Jim

Re:SQl Functions (sum, count)?


Thanks Jim.

Quote
"Jim Elden" <x@yz> wrote in message news:3ce00ba4$1_2@dnews...
> Bob

> > The following sql is excute, now how do I get at the value?

> Give the aggregate column a name, e.g.

> Select Sum(MITR_AMOUNT) AS sum_mitr_amount From MSTRAN

> Then,

> DEDataModule.DEManaQry.FieldByName('sum_mitr_amount').AsFloat (or
whatever).

> --
> Jim

Re:SQl Functions (sum, count)?


Quote
"Jim Elden" <x@yz> wrote in message news:3ce00ba4$1_2@dnews...

> Give the aggregate column a name, e.g.

> Select Sum(MITR_AMOUNT) AS sum_mitr_amount From MSTRAN

> Then,

> DEDataModule.DEManaQry.FieldByName('sum_mitr_amount').AsFloat (or

whatever).

Or forget the name and get it with

 DEDataModule.DEManaQry.Fields[0].AsFloat (or whatever).

--
Wayne Niddery (Logic Fundamentals, Inc.)
RADBooks: http://www.logicfundamentals.com/RADBooks/delphibooks.html
Those who disdain wealth as a worthy goal for an individual or a society
seem not to realize that wealth is the only thing that can prevent
poverty. - Thomas Sowell

Re:SQl Functions (sum, count)?


Hello!

Quote
> The following sql is excute, now how do I get at the value?

>   DEDataModule.DEManaQry.Close;
>   DEDataModule.DEManaQry.SQL.Clear;
>   DEDataModule.DEManaQry.SQL.Add('Select Sum(MITR_AMOUNT) From MSTRAN

  DEDataModule.DEManaQry.Fields[0].AsFloat

Good luck, Serge
--
http://www.cooldev.com/
#CoolControls, CoolMenus and more Cool VCL packs for Delphi development.
#KoolSockets, KoolStorage and other kernel level solutions.
#CdRwLib SDK, WNASPI SDK packages for CD manipulations.
#Offshore development of high quality.
CoolDev.Com

Other Threads