Subject | AW: AW: [firebird-support] Problem Select sum .. in select |
---|---|
Author | Olaf Kluge |
Post date | 2010-01-29T17:35:01Z |
Hello,
Thanks for helping.
This statement I have thought too:
-------------------------------------------
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)
-------------------------------------------
In real: select sum(wekproz) from twek_beteiligung where ma in (select nr
from tmitarbeiter where team = 4)
But I was irritated by the results. I have percent values summed and these
are like 0.04 for 4 percent - and the result was 0,43 - for 43 percent. I
have thougt wrong by seeing the result and i thougt also, that only one
value was read out and summed.
Thank you for your help. I was just irritated by the result.
I wish you a nice weekend.
Regards.
Thanks for helping.
This statement I have thought too:
-------------------------------------------
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)
-------------------------------------------
In real: select sum(wekproz) from twek_beteiligung where ma in (select nr
from tmitarbeiter where team = 4)
But I was irritated by the results. I have percent values summed and these
are like 0.04 for 4 percent - and the result was 0,43 - for 43 percent. I
have thougt wrong by seeing the result and i thougt also, that only one
value was read out and summed.
Thank you for your help. I was just irritated by the result.
I wish you a nice weekend.
Regards.
On 1/29/2010 11:25 AM, Olaf Kluge wrote:
> select sum(value) from tableB where person-id in ( FOR select id from
> tableA where group = 1) - the "for" doesn't work
Just remove the "for":
select sum(value) from tableB where person-id in (select id from tableA
where group = 1)
or try
select sum(value) from tableB where exists (select id from TableA where
TableA.person-id = TableB.id and TableA.group = 1)
--
Doug C.
-----
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?