- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
示例表:
uid time_stp traf
1 2016-01-13 00:00:00 6
1 2016-01-13 05:00:00 8
1 2016-01-13 10:00:00 14
1 2016-01-13 15:00:00 26
1 2016-01-13 20:00:00 42
...
我的SQL:
select
uid,
from_unixtime(floor(unix_timestamp(time_stp)/3600) * 3600) as tm,
sum(traf),
max(traf),
-- xxx as max_traf_time
from
group_by_time_range
group by
uid, tm;
我想对每小时的traf
进行求和,并在每个小时部分找到最大traf
和对应的time_stp
。我怎么可能用一条 SQL 语句来完成这些东西。
最佳答案
你试过吗
select
T1.uid,
from_unixtime(floor(unix_timestamp(time_stp)/3600) * 3600) as tm,
sum(traf),
(
SELECT max(traf)
FROM group_by_time_range T2
WHERE T2.uid = T1.uid
) as Max_Traf,
(
SELECT time_stp
FROM group_by_time_range T3
WHERE traf = Max_Traf
) as max_traf_time
from
group_by_time_range T1
group by
uid, tm;
关于mysql select sum, max, and another column value at the same row which the max value 停留,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34761883/
这是我的代码 />100 1000 它不按要求工作.. 当提交表单时(并且在任何错误情况下)它返回到默认选中的单选按钮,即值 = 1000 用户必须再次单击值 = 100,而目标是,如果用户选择了 1
假设我有一个透明的红色 HTML 元素。当我悬停该元素时,它应该变成纯红色。当我停止悬停该元素时,它应该动画回到第一个状态,但仅在 X 秒后。 到目前为止一切顺利,请参阅代码片段。 我的问题是当我停止
我遇到了 cookie 情况,我的 cookie 会存储一个颜色名称或根本不存储任何内容。所以让我们这样解释吧。我的 cookie 与我网站的外观有关,我的网站有 3 种外观: 正常(完全没有 coo
这是我的问题。我有一张包含三个 div 的 Bootstrap v4 卡。 A 是最重要的一个,我希望它保持在左上角。 当页面较宽时,我希望 B 和 C 在 A 的右侧。 当页面变窄时,卡片缩小,C
示例表: uid time_stp traf 1 2016-01-13 00:00:00 6 1 2016-01-13 05:00:00 8 1
我是一名优秀的程序员,十分优秀!