Subject Re: [IBO] Silly question .. hopefulle somebody can help
Author Helen Borrie
At 10:50 AM 29/10/2005 +0200, you wrote:
>Hi
>Ive got IB_Query with List of animals.
>Key field ANIMALID, DAMID, ANIMALNAME
>The DAMS(mothers) are linked to their calves by DAMID
>
>The DAMID of a record = the ANIMALID of the Dam.
>
>Now I need a list of all animals that have calved.
>
> How do I get a query for a reporting tool, with the resultset reflecting
>only the animals that have calved, but without duplictes that result from a
>JOIN.

select a1.animalid, a1.animalname
from animals a1
where exists (
select 1 from animals a2
where a2.damid = a1.animalid)

SQL puzzles don't belong here, btw - take them to firebird-support.

Helen