Subject | Re: [ib-support] Invalid Query or Bug ? |
---|---|
Author | hans@hoogstraat.ca |
Post date | 2002-02-17T02:46:21Z |
Leyne, I think I oversimplified my query
Basically I have a uniquely row numbered table, each row entry
has a field with a possible link to another row in same table.
Multiple rows to same row possible.
The rows of this table are in turn linked to a Master table.
I wanted to retieve in one query the Detail rows on some Master table
criteria, along with a count of how many other detail rows are linked
to the retrieved row.
Thus the DISTINCT to retrieve unique detail rows and count.
-----------------------------------------------------------------
Leyne, Sean wrote:
Basically I have a uniquely row numbered table, each row entry
has a field with a possible link to another row in same table.
Multiple rows to same row possible.
The rows of this table are in turn linked to a Master table.
I wanted to retieve in one query the Detail rows on some Master table
criteria, along with a count of how many other detail rows are linked
to the retrieved row.
Thus the DISTINCT to retrieve unique detail rows and count.
-----------------------------------------------------------------
Leyne, Sean wrote:
>
> Hans,
>
> > Reduced to simplest form, I ran into a problem
> >
> > SELECT A,
> > (SELECT Y.B FROM TABLE Y WHERE Y.B = X.A)
> > FROM TABLE X
> >
> > Works fine .. but
> >
> > SELECT DISTINCT A,
> > (SELECT Y.B FROM TABLE Y WHERE Y.B = X.A)
> > FROM TABLE X
>
> In both cases I would recommend using a join based syntax as in:
>
> SELECT x.A, y.B
> FROM TABLEX x
> JOIN TABLEY y WHERE Y.B = X.A
>
> Sean
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/