> On Feb 16, 2015, at 4:22 AM, [email protected] 
> [firebird-support] <[email protected]> wrote:
> 
> we have 2 tables
> For each record in Table1 there are 2 records in Table2.
> 
> Table1 (T1)
> ==
> 1
> 2
> 
> 
> Table2 (T2)
> 
> T2    T1
> ======
> 1        1
> 2        1
> 3        2
> 4        2
> 
> What is the cheapest way to get a dataset like below?
> 
> T1    T2a    T2b
> ===========
> 1       1        2
> 2       3        4
> 

Can't guarantee it's the cheapest, but you might try

select T1.T1, max T2.T1 T2a, max T2.T2 T2B
from T1 
      inner join T2 on T1.T1 = T2.T1
      group by T1.T1


Good luck,


Ann

Reply via email to