Hallo,
versuch's mal damit:
PHP-Code:
with a as (select Produkt, Min(LfdNr)
as LfdNr1
from MyTable
Group By Produkt),
b as (select x.Produkt, Min(x.LfdNr)
as LfdNr2
from MyTable x join a On a.Produkt = x.Produkt and x.lfdNr > lfdNr1
Group By x.Produkt),
a1 as (Select y.Produkt, y.lfdNr, y.Preis as Preis1 from MyTable y join a on y.Produkt = a.Produkt and lfdNr = lfdNr1),
b1 as (Select z.Produkt, z.lfdNr, z.Preis as Preis2
from MyTable z join b on z.Produkt = b.Produkt and lfdNr = LfdNr2)
select a1.Produkt, Preis1, Preis2
from a1 left outer join b1 using (Produkt)
Order By Produkt;
Birgitta
Bookmarks