Created
November 13, 2020 05:59
-
-
Save joostvanveen/0a097959a50c792176ee8e345110e48a to your computer and use it in GitHub Desktop.
Magento 2 chcek for orders with more than one shipment or invoice
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Orders with more than one shipment | |
SELECT orders.increment_id AS ordernummer, orders.created_at, count(*) as `Aantal verzendingen` FROM sales_shipment as shipments | |
LEFT JOIN sales_order AS orders ON orders.entity_id = shipments.order_id | |
GROUP BY shipments.order_id | |
HAVING `Aantal verzendingen` > 1 | |
ORDER BY orders.created_at; | |
-- Orders with more than 1 invoice | |
SELECT orders.increment_id AS ordernummer, orders.created_at, count(*) as `Aantal facturen` FROM sales_invoice as invoices | |
LEFT JOIN sales_order AS orders ON orders.entity_id = invoices.order_id | |
GROUP BY invoices.order_id | |
HAVING `Aantal facturen` > 1 | |
ORDER BY orders.created_at; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment