MySQL Forums
Forum List  »  German

SUM() später in WHERE-Klausel ?
Posted by: Mark Knochen
Date: April 11, 2012 06:18AM

Hallo,

ich möchte in einer Abfrage mit SUM() eine Spalte erzeugen und diese dann in der WHERE Klausel mit verwenden.

Also z.B:

SELECT SUM(anzahl) AS summe FROM items WHERE OrderDate > '2012-04-08 00:00:00' AND summe > 20 GROUP BY items.name

Das funktioniert so aber nicht. Gibt es eine Möglichkeit dafür?
HAVING passt nicht so richtig, da die Gruppierung erst nach dem Filter passieren sollte, was mit HAVING ja nicht möglich ist.

Danke schonmal

Mark

Options: ReplyQuote


Subject
Views
Written By
Posted
SUM() später in WHERE-Klausel ?
2236
April 11, 2012 06:18AM


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.