I have, say, 2 tables
UK_OrderandUK_Order_ItemF_OrderandF_Order_Item
UK_Order (and F_Order) has the fields: Id, orderStatus.
UK_Order_Item (and F_Order_Item) has the fields: orderId, model, and order_quantity.
I'm trying to write the SQL to return the total number of different models sold through out the UK and F but can't. So far I've come up with:
SELECT model, SUM(order_quantity) AS quantityOrdered
FROM uk_order_item
WHERE orderId
IN
(
SELECT Id FROM uk_order WHERE orderStatus = 'Incomplete'
)
GROUP BY model
and also
SELECT model, SUM(order_quantity) AS quantitySold
FROM f_order_item
WHERE orderId
IN
(
SELECT Id FROM f_order WHERE orderStatus = 'Incomplete'
)
GROUP BY model
returning eg:
Model, QuantityOrdered
Volkswagen, 3
Ford, 2
Citroen, 4
...
and then to find the total number of volkwagens sold in the UK and F, I have to do a little bit calcluation (ie volkswagenCount = uk's volkwagen's quantitySold + F's volkwagen's quantitySold
In other words, my separate queries return the total models sold for the UK, and F(rance) - I would repeat this query for Germany, Spain etc. But is there a way of returning the total number for each model sold throughout Europe (UK, France, Germany etc.)?
CREATE TABLEstatements? That'd be much better then describing them.