select *
from list a left outer join
twolist b
on a.sayac = b.satir_sayac;
number ad yazı1 yazı2
------ --- ----- ----
200222111 2 deneme renk
200222111 1 deneme önce
200789582 1 deneme sayı
200789582 3 deneme riza
200789582 4 deneme renk
200111222 3 deneme sayı
200111222 5 deneme renk
.........................
我要选择max(ad)
200222111 2 deneme renk
200789582 4 deneme renk
200111222 5 deneme renk
示例
为什么要我选择
答案 0 :(得分:0)
典型方法使用row_number()
:
select *
from list l left outer join
(select tl.*,
row_number() over (partition by satir_sayac order by ad desc) as seqnum
from twolist tl
) b
on l.sayac = tl.satir_sayac and tl.seqnum = 1;
答案 1 :(得分:0)
使用相关子查询
select t1.* from table1 t1
where ad= (select max(ad) from table1 t2 where t2.number=t1.number
and t2.yazı1=t1.yazı1
)