gpt4 book ai didi

mysql - 按类别选择行

转载 作者:行者123 更新时间:2023-11-29 02:18:49 24 4
gpt4 key购买 nike

我只需要按类别选择一行,并且选择的行必须是最低价格。

我有这个:

enter image description here

结果必须是:

enter image description here

最佳答案

首先您需要获得每堂课的最低价格:

select Class, min(price) as minimum from myTable group by Class

然后为了向其中添加其余的列,您需要将它们连接在一起:

select b.* from (
select Class, min(price) as minimum from myTable group by Class
) as a inner join myTable as b on a.class = b.class and a.minimum = b.price

关于mysql - 按类别选择行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34967995/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com