हम कुछ ऐसी ही रिपोर्ट कर रहे हैं। आपको क्या करना है:
- साधारण उत्पाद से प्रारंभ करें
- कॉन्फ़िगर करने योग्य उत्पाद पर कैटलॉग_प्रोडक्ट_सुपर_लिंक तालिका में शामिल हों
- क्वेरी के SELECT भाग में, IF => का उपयोग करें यदि साधारण उत्पाद का मान मौजूद है, तो इसका उपयोग करें, अन्यथा कॉन्फ़िगर करने योग्य उत्पाद (या दूसरी तरफ) के मूल्य का उपयोग करें
उदाहरण
SELECT
o.increment_id,
oi.order_id,
o.STATUS AS order_status,
o.created_at,
ROUND(SUM(IF(oi2.qty_ordered IS NOT NULL, IF(oi2.qty_ordered > oi.qty_ordered, oi2.qty_ordered, oi.qty_ordered), oi.qty_ordered)), 0) AS cqty_ordered,
ROUND(SUM(IF(oi2.qty_canceled IS NOT NULL, IF(oi2.qty_canceled > oi.qty_canceled, oi2.qty_canceled, oi.qty_canceled), oi.qty_canceled)), 0) AS cqty_canceled,
ROUND(SUM(IF(oi2.qty_shipped IS NOT NULL, IF(oi2.qty_shipped > oi.qty_shipped, oi2.qty_shipped, oi.qty_shipped), oi.qty_shipped)), 0) AS cqty_shipped,
ROUND(SUM(IF(oi2.qty_ordered IS NOT NULL, IF(oi2.qty_ordered > oi.qty_ordered, oi2.qty_ordered, oi.qty_ordered), oi.qty_ordered)) - SUM(IF(oi2.qty_canceled IS NOT NULL, IF(oi2.qty_canceled > oi.qty_canceled, oi2.qty_canceled, oi.qty_canceled), oi.qty_canceled)) - SUM(IF(oi2.qty_shipped IS NOT NULL, IF(oi2.qty_shipped > oi.qty_shipped, oi2.qty_shipped, oi.qty_shipped), oi.qty_shipped)), 0) AS cqty_missing
FROM sales_flat_order_item AS oi
INNER JOIN sales_flat_order AS o ON oi.order_id=o.entity_id
LEFT JOIN sales_flat_order_item AS oi2 ON oi.parent_item_id=oi2.item_id AND oi2.product_type='configurable'
WHERE oi.product_type='simple'
GROUP BY oi.order_id
HAVING cqty_missing=0 AND order_status NOT IN ('complete','canceled','closed');