SELECT distinct product.PRO_ID,PRO_TYPE_NAME,BRAND_NAME,MODEL_NAME,COLOR_NAME,quote.QT_ID,QT_AMOUNT,quotedetail.OK_AMOUNT,order_detail.ORD_NO
FROM quote,quotedetail,brand,color,model,product_type,product,product_color,`order`,`order_detail`
WHERE order.ORD_ID = 'ORD100002' and quote.QT_ID = quotedetail.QT_ID and product_color.PRO_ID = quotedetail.PRO_ID
and product.PRO_ID = product_color.PRO_ID and product.BRAND_ID = brand.BRAND_ID and product_color.COLOR_ID = color.COLOR_ID
and product.MODEL_ID = model.MODEL_ID and product.PRO_TYPE_ID = product_type.PRO_TYPE_ID and product_color.COLOR_ID = quotedetail.COLOR_ID
and product_color.NO = quotedetail.NO and quotedetail.QT_ID = order_detail.QT_ID and order.ORD_ID = order_detail.ORD_ID and order_detail.QT_NO = quotedetail.QT_NO
and order.ORD_ID in
(SELECT o.ORD_ID,o.ORD_NO,o.OK_AMOUNT,IFNULL(SUM(REV_AMOUNT),0) AS AMOUNT
FROM order_detail o LEFT OUTER JOIN receive_detail r ON r.ORD_ID=o.ORD_ID AND r.ORD_NO=o.ORD_NO
WHERE o.ORD_ID = 'ORD100002' GROUP BY o.ORD_ID,o.ORD_NO HAVING IFNULL(SUM(REV_AMOUNT),0)<o.OK_AMOUNT)
มันขึ้นว่า Operand should contain 1 column(s) อ่าครับ
and order.ORD_ID in
(SELECT o.ORD_ID, o.ORD_NO,o.OK_AMOUNT,IFNULL(SUM(REV_AMOUNT),0) AS AMOUNT
FROM order_detail o LEFT OUTER JOIN receive_detail r ON r.ORD_ID=o.ORD_ID AND r.ORD_NO=o.ORD_NO
WHERE o.ORD_ID = 'ORD100002' GROUP BY o.ORD_ID,o.ORD_NO HAVING IFNULL(SUM(REV_AMOUNT),0)<o.OK_AMOUNT)