gpt4 book ai didi

Mysql 4.0 获取最小值数据

转载 作者:行者123 更新时间:2023-11-30 00:46:20 25 4
gpt4 key购买 nike

是否可以获取最小 id 的记录并按列分组? (4.0 中)

SELECT period, activity, date
FROM (
SELECT MIN(id) id
FROM Booking
WHERE place = 'CONFERENCE'
AND Date = '05 - Mar'
GROUP BY period
) A
INNER JOIN Booking B
USING (id) ORDER BY id

可能相当于4.0版本吗?

最佳答案

我认为以下内容可以在没有子查询的情况下获取 id 的最小值:

select b1.period, b1.activity, b1.date
from booking b1 cross join
booking b2
group by b1.id, b2.period
having b1.id = min(b2.id)

您可以将 where 条件应用为:

select b1.period, b1.activity, b1.date
from booking b1 cross join
booking b2
where b2.place = 'CONFERENCE' and
b2.Date = '05 - Mar'
group by b1.id, b2.period
having b1.id = min(b2.id);

关于Mysql 4.0 获取最小值数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21335125/

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