函数名称 | 语句 | 含义 |
compare(x,n) | 对比当前时间周期内的计算结果与n秒之前时间周期内的计算结果。 | |
| compare(x,n1,n2,n3...) | 对比当前时间周期内的计算结果与n1秒、n2秒、n3秒之前时间周期内的计算结果。 |
compare(x, n)
compare(x, n1, n2, n3...)
参数 | 说明 |
x | 参数值为 double 类型或 long 类型。 |
n | 时间窗口,单位为秒。例如3600(1小时)、86400(1天)、604800(1周)、31622400(1年)。 |
* | SELECT compare(PV, 86400) FROM (SELECT count(*) AS PV)
[1860,1656,1.1231884057971016]
* |SELECT compare[1] AS today, compare[2] AS yesterday, compare[3] AS ratioFROM (SELECT compare(PV, 86400) AS compareFROM (SELECT COUNT(*) AS PV))
* |select concat(cast(current_date as varchar),' ',time) as time,compare[1] as today,compare[2] as yesterday from (select time,compare(pv, 86400) as compare from (select time_series(__TIMESTAMP__, '5m', '%H:%i:%s', '0') as time, count(*) as pv group by time limit 1000)limit 1000)order by time limit 1000
本页内容是否解决了您的问题?