gpt4 book ai didi

mysql - 使用SQL获取具有相同id的最高项目

转载 作者:行者123 更新时间:2023-11-29 07:56:51 25 4
gpt4 key购买 nike

我正在寻找一条 SQL 语句,该语句将为我提供价格最高且 link_id = 1 的所有数据 http://sqlfiddle.com/#!2/26a13/2

ID .. LINK_ID .. PRICE10 ..    1    .. 100,00020 ..    1    .. 150,00030 ..    2    .. 150,000

The following returns the correct price/offer but doesnt bring across the correct id and link_id. Is there possible statement? Or do I need to extract the data seperately?

SELECT id, p_id, MAX(offer) FROM offers 
WHERE p_id = 1

我也尝试过

SELECT * FROM offers
WHERE p_id = 1
AND offer = MAX(offer)

最佳答案

如果你只是想要最高价格记录试试这个

SELECT id, p_id, offer FROM offers 
WHERE p_id = 1 order by offer desc limit 1

关于mysql - 使用SQL获取具有相同id的最高项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24928573/

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