MySQL Forums
Forum List  »  Performance

Re: finding the better way to calculate po balance !
Posted by: Rick James
Date: June 17, 2011 10:41PM

OK, let's try with a temp table...
CREATE TEMPORARY TABLE p
    SELECT id,   SUM(Quantity) AS poqty FROM po            WHERE active  GROUP BY id;
ALTER TABLE p ADD PRIMARY KEY(id);
SELECT p.id, p,poqty, i.outqty
    FROM p
    JOIN ( SELECT poid, SUM(qty) AS outqty     FROM invoicedetail WHERE active  GROUP BY poid ) AS i
        ON p.id = i.poid
    WHERE p.poqty > i.outqty;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: finding the better way to calculate po balance !
748
June 17, 2011 10:41PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.