jeudi 30 juin 2016

Opencart report module Query

I need a report form so I'm trying to list the category, customername, email, telephone etc. Except for the category, everything works perfectly when I click the filter button. This is my query:

SELECT MIN(o.date_added) AS date_start, MAX(o.date_added) AS date_end,
       COUNT(*) AS `orders`, SUM((SELECT SUM(op.quantity) FROM `oc_order_product`
       op LEFT JOIN `oc_product_to_category` pc ON (op.product_id = pc.product_id)
       WHERE op.order_id = o.order_id GROUP BY op.order_id))
       AS products, SUM((SELECT SUM(ot.value) FROM `oc_order_total`
       ot WHERE ot.order_id = o.order_id AND ot.code = 'tax' GROUP BY ot.order_id))
       AS tax, SUM(o.total) AS `total` FROM `oc_order` o
       WHERE o.order_status_id > '0' AND DATE(o.date_added) >= '2015-10-01' AND
       DATE(o.date_added) <= '2015-10-22' And o.shipping_postcode = '4545456' AND
       pc.category_id = '72'

Please anybody correct my query.

Aucun commentaire:

Enregistrer un commentaire