MySQL Forums :: Performance :: finding the better way to calculate po balance !


Advanced Search

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
finding the better way to calculate po balance ! 1496 mo melvin 06/16/2011 04:39AM
Re: finding the better way to calculate po balance ! 660 Rick James 06/17/2011 09:57AM
Re: finding the better way to calculate po balance ! 787 mo melvin 06/17/2011 11:00AM
Re: finding the better way to calculate po balance ! 690 Rick James 06/17/2011 10:41PM
Re: finding the better way to calculate po balance ! 722 mo melvin 06/18/2011 08:56AM
Re: finding the better way to calculate po balance ! 511 Rick James 06/18/2011 09:50AM
Re: finding the better way to calculate po balance ! 643 mo melvin 06/18/2011 10:36AM
Re: finding the better way to calculate po balance ! 653 Rick James 06/18/2011 03:02PM


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.