我试过了:
SELECT DISTINCT product_id, realPriceBrutto FROM table WHERE quantity > 0 order by product_id, realPriceBrutto;
,但在我的结果中,我为某些id设置了3个不同的值( 195 - 39.68,195 - 43.19 ......) 我需要product_id的最低值realPriceBrutto。 我也尝试过:
select * from table
where (product_id,realPriceBrutto) IN (select product_id,min(realPriceBrutto) from table group by product_id);
答案 0 :(得分:2)
您可以简单地group by
product_id,然后选择realPriceBrutto的min()。
SELECT
product_id, min(realPriceBrutto)
FROM
table
WHERE
quantity > 0
group by
product_id
order by
product_id