考虑以下数据:
table:
time colA colB colC
-----------------------------------
11:30:04.194 31 250 a
11:30:04.441 31 280 a
11:30:14.761 31.6 100 a
11:30:21.324 34 100 a
11:30:38.991 32 100 b
11:31:20.968 32 100 b
11:31:56.922 32.2 1000 b
11:31:57.035 32.6 5000 c
11:32:05.810 33 100 c
11:32:05.810 33 100 a
11:32:14.461 32 300 b
现在,只要sum
相同,我colB
colC
怎么办,而不会丢失时间顺序。
所以输出结果为:
first time avgA sumB colC
-----------------------------------
11:30:04.194 31.2 730 a
11:30:38.991 32.07 1200 b
11:31:57.035 32.8 5100 c
11:32:05.810 33 100 a
11:32:14.461 32 300 b
到目前为止我所拥有的:
select by time from (select first time, avg colA, sum colB by colC, time from table)
但输出未按colC
分组。查询应该如何?
答案 0 :(得分:1)
使用differ
实现此目的的方法略有不同:
value select first time, avg colA, sum colB , first colC by g:(sums differ colC) from table