Subject Re: [firebird-support] Re: (Repost) Problem with SUM() on a computed column
Author Helen Borrie
At 02:55 AM 21/07/2003 +0000, you wrote:

>By the way, in relation to this, is it safe to do queries like:
>
>SELECT
> X.*,
> (SELECT SUM(AMOUNT)
> FROM Y
> WHERE CODE = X.CODE) AS TOTALAMOUNT
>FROM
> X

It is - provided you get the syntax right for correlating the two
keys. The above ought to be:
SELECT
X.*,
(SELECT SUM(Y.AMOUNT)
FROM Y
WHERE Y.CODE = X.CODE) AS TOTALAMOUNT
FROM X

InterBase will let you do ambiguous correlations like your
example; Firebird will let you do it dialect 1 (it should give you a
warning) but won't allow it in dialect 3. Just because you don't get a
warning in IB doesn't mean that the ambiguity is OK.

heLen






>Thanks Helen:)
>
>Joeny
>
>
>
>
>To unsubscribe from this group, send an email to:
>firebird-support-unsubscribe@yahoogroups.com
>
>
>
>Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/