Subject Re: Master-detail group by problem
Author Harriv
Thank you for fast replies. I found by myself that with stored procedure
which count rows this can be also done, a little messy but works too..

On Sun, Apr 19, 2009 at 7:30 PM, u.masotti <u.masotti@...> wrote:

> Hi Harriv,
>
> --- In firebird-support@yahoogroups.com, Harriv <harriv@...> wrote:
> >
> > On Sun, Apr 19, 2009 at 6:57 PM, Harriv <harriv@...> wrote:
> >
> > > Something like "Select .. from master where Master.MasterID =
> > > Detail.MasterID and (select number of rows from detail where
> Master.MasterID
> > > = Detail.MasterID) = 1" in "pseudo SQL".
> > >
> >
> > This is of course "... (select number of rows distinct SecondaryMasterID
> > from ...) ".
>
> Ok, HAVING clause solves your problems again.
>
> SELECT MM.fld1, MM.fld2, MM.fld3, ..., MM.fldn, COUNT(DD.SecondaryMasterID)
> FROM master MM JOIN detail dd ON (MM.MasterID=DD.MasterID)
> GROUP BY 1, 2, 3, ... n
> HAVING COUNT(DD.SecondaryMasterID) = 1
>
> CIao.
> Mimmo.
>
>
>


[Non-text portions of this message have been removed]