我有这个问题。返回每日最低和最高温度:
select year(DateTimeS),month(DateTimeS),day(DateTimeS),min(Low),max(High) from temperature
where year(DateTimeS) = 2018
group by year(DateTimeS),month(DateTimeS),day(DateTimeS)
我在这个查询中缺少两个字段,lowtime和maxtime。我不知道如何得到最小值(低)和最大值(高)发生的时间(datetimes是一个datetime字段,其余的都是十进制的)该表有如下逐分钟的温度数据:
+-----------------------+--------+-------+
| "DateTimeS" | "High" | "Low" |
+-----------------------+--------+-------+
| "2018-09-07 23:58:00" | "89" | "87" |
| "2018-09-07 23:57:00" | "88" | "85" |
| "2018-09-07 23:56:00" | "86" | "82" |
| . | | |
| etc... | | |
+-----------------------+--------+-------+
有什么想法吗?
1条答案
按热度按时间oyjwcjzk1#
在mariadb 10.3中,您应该能够使用窗口函数。所以: