Subject RE: [firebird-support] how to compare a value who comes from sub-select ref/eDN3012773479
Author dennis
The problem is that the "rest" of the customer doesn't come from an easy
outer join but from a procedure that takes some msec to compute it.



I tried to work the procedure with outer join but was much slower from
calling it like sub-select.



Is there any way in where statement to get the value by column like Delphi
expression: field[2].value ?



Kind regards

Dennis



_____

From: firebird-support@yahoogroups.com
[mailto:firebird-support@yahoogroups.com] On Behalf Of Alexandre Benson
Smith
Sent: Thursday, July 26, 2007 5:36 PM
To: firebird-support@yahoogroups.com
Subject: Re: [firebird-support] how to compare a value who comes from
sub-select ref/eDN3012773479



dennis wrote:
> I have the follow query
>
>
>
> Select
>
> Customer.name customer_name,
>
> (select sum(rest) from movements where movements.customer=customer.code)
> entity_rest
>
> Where
>
> Customer.deleted=0
>
>
>
> I want to add at where statement the follow comparison
>
> And entity_rest <>0
>
>
>
> But the column is "unknown" (ok, it is really unknown).
>
>
>
> Except to work with outer joins, how may I express this comparison?
>
>
>
> Dennis
>
>
>

Select
Customer.name customer_name,
(select sum(rest) from movements where movements.customer=customer.code)
entity_rest
from
Customer
Where
Customer.deleted=0 and
(select sum(rest) from movements where movements.customer=customer.code) <>
0

But I would use that one:

Select
Customer.name customer_name, sum(rest) entity_rest
from
Customer join
movements on (movements.customer=customer.code)
Where
Customer.deleted=0
having
sum(rest) <> 0

see you !

--
Alexandre Benson Smith
Development
THOR Software e Comercial Ltda
Santo Andre - Sao Paulo - Brazil
www.thorsoftware.com.br





[Non-text portions of this message have been removed]