SELECT B.order_id,order_status_list FROM (
SELECT order_id,
(SELECT CAST(order_status as varchar)+‘,‘ FROM zmaction
WHERE order_id=A.order_id
order by order_status desc
FOR XML PATH(‘‘)) AS order_status_list
FROM zmaction A
GROUP BY order_id
) B
where
order_status_list like ‘%8,3,2,0,%‘
or
order_status_list like‘%8,3,2,2,0,%‘
or
order_status_list like ‘%,1,%‘
or
order_status_list like ‘%8,4,%‘
or
order_status_list like ‘%2,0,%‘
---将设置order_status 为一行order_status_list
SELECT CAST(order_status as varchar)+‘,‘ FROM zmaction
WHERE order_id=A.order_id
order by order_status desc
FOR XML PATH(‘‘)) AS order_status_list
FROM zmaction A