Created
December 5, 2013 18:33
-
-
Save cavebatsofware/7810736 to your computer and use it in GitHub Desktop.
Missing product
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
select | |
o.order_id as 'NEG order', | |
d.client_reference as 'Order number', | |
o.status as 'Order status', | |
p.name as 'Product name', | |
p.sku as 'SKU', | |
p.upc as 'Barcode', | |
SUM(i.quantity) as 'Order calls for', | |
SUM(IFNULL(y.available, 0)) as 'Available', | |
SUM(IFNULL(y.allocated, 0)) as 'Allocated to other orders', | |
SUM(IFNULL(y.quantity, 0)) as 'Overall Quantity', | |
d.order_date | |
from | |
orders o | |
inner join | |
order_details d ON o.order_id = d.order_id | |
inner join | |
order_inventory i ON o.order_id = i.order_id | |
inner join | |
nep_products p ON i.product_id = p.id | |
left outer join | |
inventory y ON y.product_id = i.product_id | |
where | |
o.client_id = 'CLIENT_ID' | |
and status = 'Saved' | |
group by o.order_id , p.sku | |
order by o.order_id , p.sku |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment