SELECt O.Id
FROM Orders O
JOIN Order_details OD ON O.Id=OD.Order_Id
WHERe O.Status=’OK’
GROUP BY O.Id
HAVINg count(DISTINCT OD.Id)>1
AND SUM(CASE WHEN OD.Status NOT IN (‘S1’,’S2’)
THEN 1
ELSE 0
END) = 0
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)