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

Twistet, sorry.
This is right now:

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

I would have the sum from all values, persons assigned one group, in this
case the group 1

Sorry again

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


tableB

id 100; 101; 102
year 2010; 2010; 2010
month 1; 1 ;1
person-id 1; 2; 3
Value 100; 200; 300

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 = 300?

I could make a loop

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

Thanks for Helping

Regards