Subject | Re: SubSelect Question |
---|---|
Author | Tom Frey |
Post date | 2003-11-11T01:12:53Z |
Hi,
I just figured it out... the last table must be RDB$DATABASE and not
ABNTRADEDATA.
It works fine now.
However, is there an easier way to do something like:
SELECT (SELECT avg(volume), avg(price) from ABNTRADEDATA WHERE
volume>0), (SELECT.....
I guess the only way to achieve something like this is to do an
individual select for all of them like:
SELECT (SELECT avg(volume) FROM ABNTRADEDATA WHERE VOLUME >0),
(SELECT(avg(price) FROM ABNTRADEDATA WHERE VOLUME >0), (SELECT
avg(volume) from ABNTRADEDATA WHERE VOLUME <0);
or is there a better way?
I just figured it out... the last table must be RDB$DATABASE and not
ABNTRADEDATA.
It works fine now.
However, is there an easier way to do something like:
SELECT (SELECT avg(volume), avg(price) from ABNTRADEDATA WHERE
volume>0), (SELECT.....
I guess the only way to achieve something like this is to do an
individual select for all of them like:
SELECT (SELECT avg(volume) FROM ABNTRADEDATA WHERE VOLUME >0),
(SELECT(avg(price) FROM ABNTRADEDATA WHERE VOLUME >0), (SELECT
avg(volume) from ABNTRADEDATA WHERE VOLUME <0);
or is there a better way?
--- In firebird-support@yahoogroups.com, Daniel Rail <daniel@a...> wrote:
> Hi,
>
> At November 10, 2003, 20:25, Tom Frey wrote:
>
> > I just ran this query:
>
> > SELECT (select avg(volume) from ABNTRADEDATA where volume >0), (select
> > avg(volume) from abntradedata where volume <0) AVG_VOLUME from
> > ABNTRADEDATA;
>
> > and it took me 458seconds to execute? what's wrong here?
>
> How many records do you have in the table ABNTRADEDATA? And, what
> happens if you have an index on the field "VOLUME"(try ascending and
> descending indices)?
>
> --
> Best regards,
> Daniel Rail
> Senior System Engineer
> ACCRA Group Inc. (www.accra.ca)
> ACCRA Med Software Inc. (www.filopto.com)