Subject Re: [firebird-support] fb 1.0 => 1.5 having doesnt work any more
Author Svein Erling Tysvaer
At 17:13 08.07.2003 +0200, you wrote:
> > I want those ZiBelegNr entries that have for the "ZiBelegNr" only
> > entries with Splitdate not null.
> > e.g.
> > ZiBelegNr Splitdate
> > 1 08/08/2003
> > 1 NULL
> > 2 08/08/2003
> > 3 NULL
> > ZiBelegNr=2 is what i want to get.
>
>You should check "Splitdate" in the where clause.
>
>SELECT
> ZiBelegNr,
> Min(SplitDate) as "Splitter-Datum"
>FROM
> RsvKat
>WHERE
> SPLITDATE is not null
>GROUP BY
> ZiBelegNr

Arno, checking the SPLITDATE in the where clause wouldn't yield him the
result he wants. In the example above, your query would result in

1 08/08/2003
2 08/08/2003

and he does not want the first of these records since there also exists a
record where SPLITDATE IS NULL for ZiBelegNr 1. That's why I suggested
using NOT EXISTS as an alternative, but I can understand his logic in using
HAVING (since NULL always evaluates to NULL, then MIN(<field with one or
more records containing null>) is NULL and using HAVING <field> IS NOT NULL
should eliminate those records).

Set