Ŀǰ ÒªÇó Çó³ö ÈËÔ± ×îºóÒ»¸öԵŤ×ÊÐÅÏ¢¡£ select a.*,b.* from emplyee a inner join salary b on b.employee_id = a.employee where max(b.month)= b.month SQL code: select * from ( select t.*, row_number() over(partition by employee_id order by month desc) rn from salary t ) where rn = 1
select sum(salary) from salary group by month having month = 3 SQL code: SELECT * from SALARY WHERE (EMPLOYEE_ID,MONTH) IN (SELECT EMPLOYEE_ID,MAX(MONTH) from SALARY GROUP BY EMPLOYEE_ID)
select a.*,b.* from emplyee a inner join salary b on b.employee_id = a.id ---¿´´í×ֶΡ£ where max(b.month)= b.month