我有三列(交易者、产品、价格)的表格。我想让每个交易者获得一次,并以最高价格获得该交易者的产品。当我选择以下时,我看到重复的交易者:
select Trader, Product, Max(Price) as Price
from dbo.Sell
group by Trader, Product
order by Max(Price) desc
上面的查询如何区分交易者?下面的查询不会改变任何东西:
select distinct Trader, Product, Max(Price) as Price
from dbo.Sell
group by Trader, Product
order by Max(Price) desc
实际上,以下查询几乎是我想要的,但是我想查看产品而不是价格。
select Trader, Max(Price) as Price
from dbo.Sell
group by Trader