|
|
 |
Re: FN-FORUM: Help/guidance with a bit of tricky php/MySQL
date posted 4th March 2008 12:50
Hi Duncan,=20
Hows this:
SELECT oi=2Eproductid, oi=2Evariant, sum(oi=2Equantity) AS quantity=5Falia=
s=20
from Order=5Fitems OI
join Orders o on oi=2Eorder =3D o=2Eorderid
WHERE o=2Eorderstatus =3D Paid
group by oi=2Eproductid, oi=2Evariant
order by quantity=5Falias desc;
Joe
Original Message:
-----------------
I was wondering if you or someone else could help=2E There is an extra
layer of complication I need to add to this, then I am done:
Each Order=5FItems entry is assigned to a specific Order by orderid=2E
What I need to do is only be counting the quantities in Order=5FItems of
products and variants which form part of an order where the
orderstatus in the Order table is set to "Completed"=2E
So:
SELECT productid, variant, sum(quantity) AS quantity=5Falias from Order=5F=
items
WHERE orderstatus IN Orders =3D Paid
group by productid, variant
order by quantity=5Falias desc;
--------------------------------------------------------------------
mail2web - Check your email from the web at
http://link=2Email2web=2Ecom/mail2web
|
 |
|