select * from tb_data
a join (select max(midam) max_sal,midam as midam ,midam - MAX(midam) As rayatang from tb_data group by tb_data.idtucks
)b on a.idtucks where a.midam=b.max_sal
order by idtucks
SELECT A.IDTRUCKS, MAX(B.MIDAM) [MAX_SAL] , (B.MIDAM - MAX(B.MIDAM)) [RAYATANG] , C.NUMBER
FROM TB_DATA A
LEFT JOIN TB_DATA B ON A.IDTRUCKS = B.IDTRUCKS
LEFT JOIN TB_TABEL C ON B.IDTRUCKS = C.IDTRUCKS
GROUP BY A.IDTRUCKS
ORDER BY A.IDTRUCKS