I'm not a SQL guru.
I need to have a column which shows
order total for each customer (LL_ORDERTOTAL summed foreach customer) and order total for each country (LL_ORDERTOTAL summed foreach country) I think I need some subqueries, but like I say, it's bit beyond me.
Any assistance welcomed.
(The graphing tool I'm using claims it would handle grouping but it seems buggy.)
SELECT
CUSTOMERS.COUNTRY,
CUSTOMERS.CUSTOMERNAME,
ORDERS.ORDERNUMBER,
ORDERDETAILS.QUANTITYORDERED * ORDERDETAILS.PRICEEACH AS LINETOTAL,
(SELECT
SUM( ORDERDETAILS.QUANTITYORDERED * ORDERDETAILS.PRICEEACH)
FROM ORDERDETAILS
WHERE customers.customernumber = orders.customernumber
AND orders.ordernumber = orderdetails.ordernumber) AS LL_ORDERTOTAL
from
CUSTOMERS
inner join orders
on customers.customernumber = orders.customernumber
inner join orderdetails
on orders.ordernumber=orderdetails.ordernumber
order by
CUSTOMERS.COUNTRY,
CUSTOMERS.CUSTOMERNAME,
ORDERS.ORDERNUMBER
- eom -
I need to have a column which shows
order total for each customer (LL_ORDERTOTAL summed foreach customer) and order total for each country (LL_ORDERTOTAL summed foreach country) I think I need some subqueries, but like I say, it's bit beyond me.
Any assistance welcomed.
(The graphing tool I'm using claims it would handle grouping but it seems buggy.)
SELECT
CUSTOMERS.COUNTRY,
CUSTOMERS.CUSTOMERNAME,
ORDERS.ORDERNUMBER,
ORDERDETAILS.QUANTITYORDERED * ORDERDETAILS.PRICEEACH AS LINETOTAL,
(SELECT
SUM( ORDERDETAILS.QUANTITYORDERED * ORDERDETAILS.PRICEEACH)
FROM ORDERDETAILS
WHERE customers.customernumber = orders.customernumber
AND orders.ordernumber = orderdetails.ordernumber) AS LL_ORDERTOTAL
from
CUSTOMERS
inner join orders
on customers.customernumber = orders.customernumber
inner join orderdetails
on orders.ordernumber=orderdetails.ordernumber
order by
CUSTOMERS.COUNTRY,
CUSTOMERS.CUSTOMERNAME,
ORDERS.ORDERNUMBER
- eom -