就是数据表中2行数据,他们有共同的order_id,想根据获取的字段不同信息不同(指的是load_or_unload字段,这里只有2,1),然后对目标字段的字符串(desination)进行不一样的截取。
大家有啥思路么
数据表截图获取截图
附上sql语句
[SQL] 纯文本查看 复制代码 SELECT
agv.ID AS task_id,
agv.task_set_no AS order_id,
agv.parameter_int4_2 AS load_or_unload,
SUBSTRING(ORDE.PARAMETERS,1,34) AS destination, --目前只能单一对字段截取
agv.created_timestamp AS task_create_time,
agv.last_updated_timestamp AS task_finish_time
FROM
layer2_pallet.agv_task agv
INNER JOIN (
SELECT
o.order_id,
oc.PARAMETERS
FROM
layer4_1_om."order" o,
layer4_1_om."order_command" oc
WHERE
o.ts_id = 'p2p'
AND o.order_id = oc.id
AND create_time BETWEEN '2022-08-31 00:00:00'
AND '2022-08-31 23:59:59'
ORDER BY
create_time
) AS ORDE ON agv.task_set_no = CAST ( ORDE.order_id AS VARCHAR )
WHERE
parameter_int4_2 = 2
OR parameter_int4_2 = 1
ORDER BY
agv.task_set_no ASC,
agv.created_timestamp ASC,
parameter_int4_2 DESC |