select t1.id_s, t1. grade, t2.grade
from table1 as t1,
left join (
select id_s, grade
from table2 t3
inner join( select id_s, max(num) mx from table2 group by id_s) t4
on t3.num = t4.ms
) as t2
on t2.id_s=t1.id_s
หรือ
Code (SQL)
select t1.id_s, t2.grade, t3.grade
from ( select id_s, max(num) mx from table2 group by id_s) t1
left join table1 t2 on t1.id_s=t2.id_s
left join table2 t3 on t1.id_s=t3.id_s and t1.mx=t3.num