34,590
社区成员
发帖
与我相关
我的任务
分享
with aa as
(select row_number()over(partition by mmsi order by createtime desc )n,* from tb)
select distinct a1.*,case when a1.portnum<=a2.portnum then 0 else 1 end as hangxian from (
select * from aa
where n=1)a1 join (select * from aa
where n=2)a2 on a1.mmsi=a2.mmsi