This is solution: 
select * from tabella A where Group_ID in (Select min(Group_ID) in tabella B
where B.ID=A.ID);

 -------Messaggio originale-------
 
Da: 'Leyne, Sean' s...@broadviewsoftware.com [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]

  • [firebird-su... Maya Opperman m...@omniaccounts.co.za [firebird-support]
    • Rif: [f... 'Raffaele Confalone' r.confal...@libero.it [firebird-support]
    • [firebi... Maya Opperman m...@omniaccounts.co.za [firebird-support]
      • [fi... 'Leyne, Sean' s...@broadviewsoftware.com [firebird-support]
        • ... 'Raffaele Confalone' r.confal...@libero.it [firebird-support]
          • ... 'Leyne, Sean' s...@broadviewsoftware.com [firebird-support]
        • ... Maya Opperman m...@omniaccounts.co.za [firebird-support]
    • Re: [fi... setysvar setys...@gmail.com [firebird-support]

Reply via email to