需要唯一具有最大BookingVersion 分组依据的行 shipmentNumber, shipmentDate,
elect max(BookingVersion) BookingVersion, flightId, shipmentNumber, shipmentDate, FlightOffPoint, IIF(BookingStatusCode = 'XX', 'XX','SS') BookingStatusCode
from Exp_BookingDelta where flightid='625436'
group by flightId, shipmentNumber, shipmentDate, FlightOffPoint, BookingStatusCode
order by max(BookingVersion) desc
谁能解释我所缺少的吗?
当前结果:
BookingVersion flightId shipmentNumber shipmentDate FlightOffPoint BookingStatusCode
4 625436 61823647238 2019-12-04 LHR XX
2 625436 61823647238 2019-12-04 LHR SS
1 625436 61826374895 2019-12-06 LHR XX
0 625436 61825364780 2019-11-26 LHR SS
0 625436 61825364791 2019-11-26 LHR SS
0 625436 61825364802 2019-11-26 LHR SS
0 625436 61826374895 2019-12-06 LHR SS
预期结果:
BookingVersion flightId shipmentNumber shipmentDate FlightOffPoint BookingStatusCode
4 625436 61823647238 2019-12-04 LHR XX
1 625436 61826374895 2019-12-06 LHR XX
0 625436 61825364780 2019-11-26 LHR SS
0 625436 61825364791 2019-11-26 LHR SS
0 625436 61825364802 2019-11-26 LHR SS
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。