对于相同的时间戳,我有2种不同的类型和一个合计的值。我想创建一个检索时间戳、value1、value2的查询,其中value1是type1的总数,value2是type2的总数。
我的sum字段是一个数字[],但在我正在处理的类型中只有一个值。在其他情况下,是一个具有不同值的数组。
我试过了:
select distinct type, timestamp, sum
from default_dataset
where type like 'probing_%'
group by type, timestamp, sum
limit 10正在做什么
select timestamp, type, sum
from default_dataset
where type like 'probing_%'
order by timestamp desc
limit 50我有过
2017-07-13 12:24:38+01 | probing_repated | 50
2017-07-13 12:24:38+01 | probing_live | 10
2017-07-13 12:24:38+01 | probing_live | 15
2017-07-13 12:24:38+01 | probing_repated | 10
2017-07-13 12:19:00+01 | probing_live | 11
2017-07-13 12:19:00+01 | probing_repeated | 40
2017-07-13 12:19:00+01 | probing_repeated | 21
2017-07-13 12:19:00+01 | probing_live | 26我想要一个像timestamp,type,sum(sum)这样的结果
2017-07-13 12:24:38+01 | probing_repated | 65
2017-07-13 12:24:38+01 | probing_live | 25
2017-07-13 12:19:00+01 | probing_live | 37
2017-07-13 12:19:00+01 | probing_repeated | 61有没有人?
发布于 2017-07-13 19:42:20
你试过sum1吗?..如下所示:
select timestamp, type, sum(sum[1])
from default_dataset
where type like 'probing_%'
group by "timestamp", "type"
limit 50要将所有内容放在一列中,只需查看结果:
with a as (
select timestamp a, type b, sum(sum[1]) c
from default_dataset
where type like 'probing_%'
group by "timestamp", "type"
)
select concat(a,' ',b,' ',c) from ahttps://stackoverflow.com/questions/45079222
复制相似问题