Subject | RE: [firebird-support] RE: Possible to use FIRST 1 inside a group by? |
---|---|
Author | Leyne, Sean |
Post date | 2015-07-29T17:25:33Z |
> This is solution:Are you sure that works? It doesn't see to answer Maya original question.
> select * from tabella A where Group_ID in (Select min(Group_ID) in tabella B
> where B.ID=A.ID);
It also would read n^2 rows from the table.
Sean
>
> -------Messaggio originale-------
>
> Da: 'Leyne, Sean' Sean@... [firebird-support]
> Data: 29/07/2015 18.59.03
> A: firebird-support@yahoogroups.com
> Oggetto: [firebird-support] RE: Possible to use FIRST 1 inside a group by?
>
>
> Maya,
>
> > Might not be the most efficient method, but this works:
>
> Unfortunately, it is least efficient method -- you will read each table row
> n^2 times
>
> Try:
>
> SELECT
> T.ID
> T.GroupID
> T2.FKCode
> T2.Value
> FROM (
> select MIN (ID) as ID, GroupID
> from MyTable
> GROUP BY GroupID
> ) T
> JOIN MyTable T2 ON T2.ID = T.ID
>
> Sean
>
>
>
>
>
> [Non-text portions of this message have been removed]
>
>
>
> ------------------------------------
> Posted by: "Raffaele Confalone" <r.confalone@...>
> ------------------------------------
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++
>
> Visit http://www.firebirdsql.org and click the Documentation item on the
> main (top) menu. Try FAQ and other links from the left-side menu there.
>
> Also search the knowledgebases at
> http://www.ibphoenix.com/resources/documents/
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> ++++++++
> ------------------------------------
>
> Yahoo Groups Links
>
>
>