Subject Re: Sub select paramerter with null value problem
Author Svein Erling Tysvær
--- In firebird-support@yahoogroups.com, "jasajona" wrote:
> Hello,
>
> I just found out that some of my query work wrong. This is query
> example:
>
> SELECT
> A.Field1,
> sum(A.Field2),
> (SELECT sum(B.Field2) FROM B WHERE B.Field1 = A.Field1)
> FROM A
> GROUP BY A.Field1
>
> When A.Field1 get value NULL and sets it to subselect query,
> subselect query do not work correctly (allways returning null
> result). How to solve this problem?

Consider the following two conversations:

1)
"How old am I?"
"When were you born?"
"12 February 1970"
"Then you're 12921 days old"

2)
"How old am I?"
"When were you born?"
"I don't know..."
"Then I don't know your age"

NULL is a state that simply means unknown. Anything that is based on
an unknown value will also be unknown (and it is unknown whether or
not an unknown value is equal to other values, whether or not they are
unknown). Hence, NULL is the correct answer. As another answer to your
question says, 0 is completely different from NULL, and - unlike NULL
- may be summed or joined freely.

HTH,
Set