Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joostvanveen/0a097959a50c792176ee8e345110e48a to your computer and use it in GitHub Desktop.
Save joostvanveen/0a097959a50c792176ee8e345110e48a to your computer and use it in GitHub Desktop.
Magento 2 chcek for orders with more than one shipment or invoice
-- 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