Subject Re: [firebird-support] Subselect causes slow query
Author Helen Borrie
Sorry for being a bit premature on the Send button....


>select
> di2.ID,
> di2.NDC,
> di2.FRMTD_NDC,
> di2.UPC_HRI,
> ....
>from
> MDDB_DRUGITEM di2
>where
> di2.NDC is not null
> and di2.UPC_HRI is not null /* eliminates all rows where one or the
>other is null */
> and exists (
> select
> d1.ndc
> from mddb_drugitem d1
> where d1.ndc = di2.NDC

/* need this too */
and d1.upc_hri is not null

> group by 1
> having count(d1.ndc) > 1)

./hb