Hi,
I Have some troubles with a SQL Statment. The result should be a list of the same Articles with current price and calculated price per kg.
Each article has more prices.
The querie works fine with 1 article:
Code:
SELECT Preis.ArtikelID, Preis.BruttoPreis, Artikel.Bezeichnung, Artikel.Einheit, Artikel.Liefereinheit, Artikel.Gewicht, Artikel.ArtikelNr, round((Preis.BruttoPreis / Artikel.Gewicht *1 ),2) as KiloPreis
FROM Preis INNER JOIN Artikel ON Preis.ArtikelID = Artikel.ArtikelID
WHERE (((Preis.Preisid)=
(SELECT Max(Preis.PreisID)
FROM Preis WHERE Artikelid = 10113)));
My problem is if i try to search for all Artikel which contains for example orange...
I thought this would work:
Code:
SELECT Preis.ArtikelID, Preis.BruttoPreis, Artikel.Bezeichnung, Artikel.Einheit, Artikel.Liefereinheit, Artikel.Gewicht, Artikel.ArtikelNr, Round((Preis.BruttoPreis/Artikel.Gewicht*1),2) AS KiloPreis, Artikel.Bezeichnung
FROM Preis INNER JOIN Artikel ON Preis.ArtikelID = Artikel.ArtikelID
WHERE (((Preis.Preisid) =
(SELECT Max(Preis.PreisID)
FROM Preis WHERE Artikelid IN
(SELECT ArtikelID
FROM Artikel WHERE Bezeichnung like '*Orange*'))));
I get 1 Article instead of all articles which contain Orange... I think the problem is the MAX function but i have no idea how i can solve it.
Does anyone have an idea ? or solution ?
Best Regards Matthias