Hi folks,
I need to add: ORDER BY TotalShipped DESC
to get rows with large numbers first. Any help welcome.I've tried vairous places and get SQL errs.
Thanks
Milton
-----------
select country,
sum(TotalShipped)as shipped,
sum(TotalCancelled) as cancelled,
sum(TotalInProcess) as inProcess,
sum(TotalDisputed) as disputed,
sum(TotalOnHold) as onHold,
sum(TotalResolved) as resolved
from (
SELECT country,
case when status = 'Cancelled'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalCancelled,
case when status = 'Shipped'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalShipped ,
case when status = 'In Process'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalInProcess,
case when status = 'Disputed'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalDisputed,
case when status = 'On Hold'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalOnHold,
case when status = 'Resolved'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalResolved
FROM CLASSICMODELS.CUSTOMERS,
CLASSICMODELS.ORDERS,
CLASSICMODELS.ORDERDETAILS
WHERE CLASSICMODELS.CUSTOMERS.CUSTOMERNUMBER = CLASSICMODELS.ORDERS.CUSTOMERNUMBER
AND CLASSICMODELS.ORDERS.ORDERNUMBER = CLASSICMODELS.ORDERDETAILS.ORDERNUMBER
) as m1
group by country
I need to add: ORDER BY TotalShipped DESC
to get rows with large numbers first. Any help welcome.I've tried vairous places and get SQL errs.
Thanks
Milton
-----------
select country,
sum(TotalShipped)as shipped,
sum(TotalCancelled) as cancelled,
sum(TotalInProcess) as inProcess,
sum(TotalDisputed) as disputed,
sum(TotalOnHold) as onHold,
sum(TotalResolved) as resolved
from (
SELECT country,
case when status = 'Cancelled'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalCancelled,
case when status = 'Shipped'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalShipped ,
case when status = 'In Process'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalInProcess,
case when status = 'Disputed'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalDisputed,
case when status = 'On Hold'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalOnHold,
case when status = 'Resolved'
then CLASSICMODELS.ORDERDETAILS.QUANTITYORDERED * CLASSICMODELS.ORDERDETAILS.PRICEEACH else 0 end as TotalResolved
FROM CLASSICMODELS.CUSTOMERS,
CLASSICMODELS.ORDERS,
CLASSICMODELS.ORDERDETAILS
WHERE CLASSICMODELS.CUSTOMERS.CUSTOMERNUMBER = CLASSICMODELS.ORDERS.CUSTOMERNUMBER
AND CLASSICMODELS.ORDERS.ORDERNUMBER = CLASSICMODELS.ORDERDETAILS.ORDERNUMBER
) as m1
group by country