MySQL Forums
Forum List  »  German

Re: Kombinieren von SUM() / WHERE / GROUP BY
Posted by: Mark Knochen
Date: April 20, 2012 01:02AM

Hallo Thomas,

danke nochmals für den Aufwand zur Lösung des Problems - so funktioniert es jetzt. Dann werde ich mal den SELECT so erweitern, dass er dann mit allen benötigten Felder kommt - und mal sehen, wie es sich dann mit der Performance verhält ...

der Block


MIN(i.ItemName) AS Itemname, 
       SUM(
           (SELECT SUM(invoicelines.FullPrice * invoicelines.OrderQty)
              FROM invoicelines
             WHERE invoicelines.ItemNrInt = i.ItemNrInt
               AND invoicelines.OrderQty > '0'
               AND invoicelines.Status = 'AUS'
               AND invoicelines.OrderDate BETWEEN '2011-03-01 00:00:00' AND '2011-03-31 23:59:59'
            )
           ) AS PriceTotal,
       SUM(i.loc001 + i.loc002) AS stockValue,
       SUM(i.AvailableStock) AS stockValueAvailable


kommt ja identisch 2x ... hier müssten dann an beiden Stellen die andere Spalten hinzugefügt werden und vermutlich alle entweder mit MIN oder SUM() ?

Danke


Mark

Options: ReplyQuote




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.