老兄,做死我了,這個方法你看看,不過只能查一個,你說的多個商店,你再想想辦法吧。餓死了,還沒吃飯。十點鐘了。
select a.productid,a.productname,
(select max(price) from sale as b where b.productid=a.productid) as maxprice,
(select seller from sale as b
where price=(select max(price) from sale as b where b.productid=a.productid)
and b.productid=a.productid
) as maxseller,
(select min(price) from sale as b where b.productid=a.productid) as minprice,
(select seller from sale as b
where price=(select min(price) from sale as b where b.productid=a.productid)
and b.productid=a.productid
) as maxseller
from product a