Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

Re: FN-FORUM: Help/guidance with a bit of tricky php/MySQL

date posted 4th March 2008 12:56

On Tue, 2008-03-04 at 14:04 +0000, Duncan Glendinning wrote:
> Morning Joe,
>
> Thanks for that, worked a treat, except I had to change it to
>
> select productid, variant, sum(quantity) AS quantity_alias from Order_items
> group by productid, variant
> order by quantity_alias desc;
>
> I was wondering if you or someone else could help. There is an extra
> layer of complication I need to add to this, then I am done:
> Each Order_Items entry is assigned to a specific Order by orderid.
> What I need to do is only be counting the quantities in Order_Items of
> products and variants which form part of an order where the
> orderstatus in the Order table is set to "Completed".
>
> So:
>

You were nearly there, I think. Try:

SELECT productid, variant, sum(quantity) AS quantity_alias from Order_items
WHERE orderstatus IN ( select Orders_id from orders where status = 'Paid' )
group by productid, variant
order by quantity_alias desc;

(If this is mysql you need a 4.x/5.x version for the subselect)

Graham



>
> Any ideas?
>
> Thanks for your help by the way, and sorry for bugging you!!!
> Cheers,
>
> Duncan
>



Messages by Day
March 31st 2008
March 30th 2008
March 29th 2008
March 28th 2008
March 27th 2008
March 26th 2008
March 25th 2008
March 24th 2008
March 23rd 2008
March 22nd 2008
March 21st 2008
March 20th 2008
March 19th 2008
March 18th 2008
March 17th 2008
March 16th 2008
March 15th 2008
March 14th 2008
March 13th 2008
March 12th 2008
March 11th 2008
March 10th 2008
March 9th 2008
March 8th 2008
March 7th 2008
March 6th 2008
March 5th 2008
March 4th 2008
March 3rd 2008
March 2nd 2008
March 1st 2008


Messages by Month
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000