sql分组查询partition
select b.STCD,b.STNM,t.EQPTP,t.EXKEY
from ST_STBPRP_B b
left join ST_GATE_R t on b.STCD = t.STCD
where t.TM = (select max(s.tm) as mtm from ST_GATE_R s where s.STCD = b.STCD group by s.STCD)
select s.* from (
select t.STCD,b.STNM,t.EQPNO,t.TM,ROW_NUMBER() over (partition by t.stcd ORDER BY t.tm desc) as numtm
from ST_GATE_R t
left join ST_STBPRP_B b on b.STCD = t.STCD
) s where s.numtm = 1