Hallo, ich versuche mich gerade an eine SQL Abfrage, bei welcher der höchste Preis ausgegeben werden soll.
Die Tabellen sind wie folgt
Tabelle 1
Artikelnr | Produkte
----------------------
1 | Produkt1
2 | Produkt2
3 | Produkt3
Tabelle 2
Attributnr | Artikelnr | Bezeichnung | Preis
---------------------------------------------
1 | 1 | Attribut1 | 9.99
2 | 1 | Attribut2 | 119.00
3 | 1 | Attribut3 | 20.00
4 | 2 | Attribut4 | 39.99
5 | 2 | Attribut5 | 219.00
6 | 3 | Attribut6 | 80.00
Wie folgt Frage ich die Daten ab
SELECT tabelle2.preis FROM tabelle1 JOIN tabelle2 ON tabelle2.artikelnr=tabelle2.artikelnr
Ausgabe
9.99
39.99
80.00
Nun möchte ich den MAX Preis von allen Zeilen ausgeben
SELECT MAX(tabelle2.preis) FROM tabelle1 JOIN tabelle2 ON tabelle2.artikelnr=tabelle2.artikelnr
Eigentlich sollte nun der Preis 80.00 ausgegeben werden. In der Ausgabe erscheint jedoch der Preis 219.00.
Was mache ich denn da falsch?!?