Subject Re: SubSelect Question
Author Tom Frey
Hi,

sorry maybe I misworded it.

I just have one table with the volume column and I'd like to do only
one select statement that gives me both the averages for the negative
volume numbers and the positive numbers which reside in the same column

--- In firebird-support@yahoogroups.com, Helen Borrie <helebor@t...>
wrote:
> At 10:57 PM 10/11/2003 +0000, you wrote:
> >Hi,
> >
> >maybe someone can help me with this:
> >I have a table with a column that holds negative and positive volume
> >numbers.
> >e.g:
> >100
> >-250
> >300
> >50
> >you get the idea ;)
> >
> >Is there a way to select in one SELECT statement an AVG for all
> >negative volumes and all positive volumes?
>
> Since your Subject says "SubSelect Question" I assume you want to
> sub-select into a different table:
>
> select
> m.x. m.y, ...
> (select avg(a.volume) from that_table a
> where a.volume >=1 and a.some_key = m.some_key) as posvalue,
> (select avg(b.volume) from that_table b
> where b.volume < 1 and b.some_key = m.some_key) as negvalue,
> m.z
> from main_table m
> where....
>
> heLen