Subject AW: [firebird-support] Problem Select sum .. in select
Author Olaf Kluge
.. Sorry, forget to change

select sum(value) from tableA where person-id in ( FOR select id from
tableB where group = 1) - the "for" doesn't work

Hello,

i have an urgent problem.

tableA (this ist just a simple example for the situation - persons)

id 1 2 3
person (name) heiko bernd silke
group 1 1 2
value 10 5 8

tableB

id 1 00 101 102
year 2010 2010 2010
month 1 1 1
person-id 1 2 3
other fields

I would like the sum of values (tableA, example - all persons in group 1 -
and this with one sql-statement

select sum(value) from tableA where person-id in (select nr from
tmitarbeiter where group = 1)

Unfortunately, the result is only the first value of the first person.

select sum(value) from tableA where person-id in ( FOR select nr from
tmitarbeiter where group = 1) - the "for" doesn't work

Is there a other way to bring me the result of example = 15?

I could make a loop

For select...
Sum = sum + value... - but I would do this with a simpler statement.

Thanks for Helping

Regards