Subject Re: [firebird-support] SQL help please
Author Helen Borrie
At 09:02 AM 24/02/2005 +0200, you wrote:

>Will the following two queries give the same results? Is there a beneifit to
>doing it either way?
>
>SELECT SUM(Y.TOTAL) FROM TABLEONE X
>LEFT OUTER JOIN TABLETWO Y ON X.LINK = Y.LINK AND Y.DELETED = 'N'
>WHERE X.LINK = 1
>
>SELECT SUM(Y.TOTAL) FROM TABLEONE X
>LEFT OUTER JOIN TABLETWO Y ON X.LINK = Y.LINK
>WHERE X.LINK = 1 AND Y.DELETED = 'N'

Stylistically the second one is correct, although logically both achieve
the same thing.

Make it a habit to properly separate join criteria from search criteria,
though. Some class interfaces, particularly those that do magic with
replaceable parameters, have trouble parsing statements that jumble up
static syntax elements with dynamic ones...clean code habits tend to make
your work self-documenting, too.

./hb