请简化sql: select d.document_id , d.workflow_order_id,e.handle_result, d.workflow_id ,d.process_id -- ,e.workflow_id as workflow_id2 from (select doc.document_id , wo.workflow_order_id,wo.workflow_id,doc.process_id from document doc inner join workflow_order wo on doc.document_id = wo.object_id where doc.document_id = 1476093058673315842 and wo.workflow_id in( SELECT CASE WHEN process_id IN (1, 2) THEN 1470275488528011266 WHEN process_id IN (3, 4) THEN 1470275525786034178 END AS workflow_id FROM document WHERE document_id = 1476093058673315842 ) and wo.status != 3 )as d inner join (select wo.workflow_order_id,wr.handle_result,wr.workflow_id from workflow_record wr inner join workflow_order wo on wo.workflow_order_id = wr.workflow_order_id where wo.workflow_order_id in ( select wo.workflow_order_id from document doc inner join workflow_order wo on doc.document_id = wo.object_id where doc.document_id = 1476093058673315842 and wo.workflow_id in( SELECT CASE WHEN process_id IN (1, 2) THEN 1470275488528011266 WHEN process_id IN (3, 4) THEN 1470275525786034178 END AS workflow_id FROM document WHERE document_id = 1476093058673315842 ) and wo.status != 3 ) ) as e on d.workflow_order_id = e.workflow_order_id ;
时间: 2024-05-05 14:17:37 浏览: 128
简化后的SQL语句如下:
```
SELECT d.document_id, d.workflow_order_id, e.handle_result, d.workflow_id, d.process_id
FROM (
SELECT doc.document_id, wo.workflow_order_id, wo.workflow_id, doc.process_id
FROM document doc
INNER JOIN workflow_order wo ON doc.document_id = wo.object_id
WHERE doc.document_id = 1476093058673315842
AND wo.workflow_id IN (
SELECT CASE
WHEN process_id IN (1, 2) THEN 1470275488528011266
WHEN process_id IN (3, 4) THEN 1470275525786034178
END AS workflow_id
FROM document
WHERE document_id = 1476093058673315842
)
AND wo.status != 3
) AS d
INNER JOIN (
SELECT wo.workflow_order_id, wr.handle_result, wr.workflow_id
FROM workflow_record wr
INNER JOIN workflow_order wo ON wo.workflow_order_id = wr.workflow_order_id
WHERE wo.workflow_order_id IN (
SELECT wo.workflow_order_id
FROM document doc
INNER JOIN workflow_order wo ON doc.document_id = wo.object_id
WHERE doc.document_id = 1476093058673315842
AND wo.workflow_id IN (
SELECT CASE
WHEN process_id IN (1, 2) THEN 1470275488528011266
WHEN process_id IN (3, 4) THEN 1470275525786034178
END AS workflow_id
FROM document
WHERE document_id = 1476093058673315842
)
AND wo.status != 3
)
) AS e ON d.workflow_order_id = e.workflow_order_id;
```
阅读全文