Subject Re: [ib-support] SUM + row_count
Author Helen Borrie
At 12:24 PM 22-11-02 +0100, you wrote:
>Hi,
>
>What is SQL way to know how many rows was selected to make SUM in following
>situation:
>
>SELECT SUM("col_1") FROM "table" where "col_2"="2" INTO :"answer";

In a stored procedure:

declare variable answer integer;
declare variable rows_in_total integer;
begin
Select sum("Col_1"), count("col_1") into :answer, :rows_in_total
where "col_2" = '2';
....

In DSQL:

Select sum("Col_1") as Total, count("col_1") AS answer
where "col_2" = '2';

heLen