微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

根据文档名称获取唯一的最小日期

如何解决根据文档名称获取唯一的最小日期

我在尝试通过文档类型名称获取最小日期时遇到问题,它会提取最小日期并将相同的值应用于两个值。所以我有一个订单,作为预订确认和预订确认,我需要两者的最小创建日期作为它们的唯一日期......有没有一种简单的方法可以调整下面的代码? 当前数据

订单编号 文档类型 bookingConfirmationUploaded
403455 BKG AKN 2021-04-15T14:09:14
403455 BKG CNFM 2021-04-15T14:09:14
403455 BKG CNFM 2021-04-15T14:09:14

成为数据

订单编号 文档类型 bookingConfirmationUploaded
403455 BKG AKN 2021-04-15T14:09:14
403455 BKG CNFM 2021-04-17T09:39:10

所有代码

select orderId,team,DocType,workgroups,status,carrier,

TIMESTAMPDIFF(MINUTE,bookingRequest,bookingConfirmationUploaded)/60.0 为 'startToFinish(HRs)',预约申请, 预订确认已上传, 起源, POL_代码, POD_code,目的地, 容器类型, 数量, 出发

来自 ( 选择订单 ID, 团队, 文档类型, 工作组, 地位, 载体, 预约申请, 预订确认已上传, 起源, POL_代码, POD_code,目的地, 容器类型, 数量, 离开 从 (

选择 CAST(Order.id AS CHAR CHaraCTER SET utf8) AS orderId,Org.name 作为团队, Order.status,(从 Org 中选择名称,其中 id = Voyage.carrierId)作为承运人, Order.createdAt 作为预订请求,

(select min(Document.createdAt) as bookingConfirmationUploaded from Document

inner join OrgDocumentType on Document.orgDocumentTypeId = OrgDocumentType.id and OrgDocumentType.name in ('Booking Confirmation','Booking AckNowledgement')

其中 Document.orderId = Order.id) 作为 bookingConfirmationUploaded, OrgDocumentType.name 为 'DocType',QuoteCriteria.Containertype 作为 Containertype, Order.Quantity 作为数量QuoteCriteria.Fromaddress 为 'Origin',QuoteCriteria.Fromportcode 为“POL_code”, QuoteCriteria.ToAddress 为“目的地”, QuoteCriteria.Toportcode 为“POD_code”, concat(date(QuoteCriteria.Estimateddate),'') AS 'Departure',

if(Voyage.originAtd 不为空,Voyage.originAtd,Voyage.originEtd )AS 发货日期,CONCAT('[',_workgroup.name,']') 作为 WorkgroupsOrder 加入 Org on((Order.orgId = Org.id)) left join Voyage on((Order.selectedVoyageId = Voyage.id)) left join QuoteCriteria on((Order.id = QuoteCriteria.orderId)) left join Document on((Order.id = Document.OrderId)) 在 OrgDocumentType.orgDocumentTypeId = Document.id 上左加入 OrgDocumentType 左加入 OrderWorkgroup _orderWorkgroup ON Order.id=_orderWorkgroup.orderId 左加入工作组 _workgroup ON _workgroup.id = _orderWorkgroup.workgroupId 在哪里 Org.name 喜欢“Yara%” 和 Order.status 不像 'CANCELLED%' 和 OrgDocumentType.id in ('2517','2154') 和_workgroup.name in ('Porsgrunn Plant','Porsgrunn Plant-','BUMA','BUMA-') 和 Order.createdAt >= convert_tz('2021-04-15 00:00:00.000','UTC',@@session.time_zone)

) tmp2
) tmp3 order by bookingRequest;

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。