Subject | Re: SQL query |
---|---|
Author | ibfa2000 |
Post date | 2002-04-26T13:26:30Z |
Set,
Thanks for you answer, it works very fine, even adapted with my real
tables and with real datas. It is a particulary clever query :-)
Moreover, it executes very fast.
Thanks for your help.
Fabrice
--- In ib-support@y..., Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
Thanks for you answer, it works very fine, even adapted with my real
tables and with real datas. It is a particulary clever query :-)
Moreover, it executes very fast.
Thanks for your help.
Fabrice
--- In ib-support@y..., Svein Erling Tysvær
<svein.erling.tysvaer@k...> wrote:
> Thanks Fabrice, I like such brain teasers!SI.QUANTITY)
>
> SELECT SET_ID
> FROM SET S
> WHERE NOT EXISTS (SELECT 1 FROM SET_ITEM SI
> WHERE SI.SET_ID = S.SET_ID
> AND NOT EXISTS (SELECT 1 FROM SET_ITEM SI2
> WHERE SI2.SET_ID = :S
> AND SI2.ITEM_ID = SI.ITEM_ID
> AND SI2.QUANTITY =
> AND NOT EXISTS (SELECT 1 FROM SET_ITEM SISI.QUANTITY)
> WHERE SI.SET_ID = :S
> AND NOT EXISTS (SELECT 1 FROM SET_ITEM SI2
> WHERE SI2.SET_ID = S.SET_ID
> AND SI2.ITEM_ID = SI.ITEM_ID
> AND SI2.QUANTITY =
>that
> The first exists checks that the SET_ID doesn't contain any records
> doesn't exist for :S, whereas the second exists should cater forthe opposite.
>haven't
> For the supersets just use the second half of the where clause.
>
> Note that I've never tried using exists within exists, that I
> actually executed (nor prepared) the above statement, and that I donot
> know at what speed such a query would execute.stored
>
> Tell me if it works - if not, I would recommend you to write a
> procedure.table)
>
> HTH,
> Set (that's what I call myself in English, not the name of your