Board index » delphi » how can i save a sql-sum-calculation in a variable

how can i save a sql-sum-calculation in a variable

Hi everybody,

I have a problem and need help. I have a sql-statment like:
 SELECT SUM(Spalte)
 FROM <Tabelle>
WHERE Datum Between '01.01.99' AND '31.01.99';

My Question:
Can I store the result in a Variable?
I want to show the result in a edit-component!

with many thanks and best regards
Christian Huber

 

Re:how can i save a sql-sum-calculation in a variable


Christian Huber <christian1.hu...@stud.fh-regensburg.de> wrote :
374D4EC0.BEE84...@stud.fh-regensburg.de...

Quote
> Hi everybody,

> I have a problem and need help. I have a sql-statment like:
>  SELECT SUM(Spalte)
>  FROM <Tabelle>
> WHERE Datum Between '01.01.99' AND '31.01.99';

> My Question:
> Can I store the result in a Variable?
> I want to show the result in a edit-component!

> with many thanks and best regards
> Christian Huber

Hi,
in this case its easier to work with an alias:

select sum(spalte) Jahressumme
from tabelle
where datum between...

After you've opened the query, you can acces the value
with:
edit1.text := floattostrf(query1.fieldbyname('jahressumme').asfloat,
fffcurrency, 8,2);

If the select statement doesn't work you'll have to use
select sum(spalte) as Jahressumme

instead.

Bye
Uli

Other Threads