Function | Syntax | Description |
compare(x,n) | Compares the calculation result of the current time period with the calculation result of a time period n seconds before. | |
| compare(x,n1,n2,n3...) | Compares the calculation result of the current time period with the calculation results of time periods n1, n2, and n3 seconds before. |
compare function is used to compare the calculation result of the current time period with the calculation result of a time period n seconds before.compare (x, n)
compare (x, n1, n2, n3...)
Parameter | Description |
x | The parameter value is of the double or long type. |
n | Time window. Unit: seconds. Example: 3600 (1 hour), 86400 (1 day), 604800 (1 week), or 31622400 (1 year). |
86400 indicates the current time minus 86400 seconds (1 day).* | 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))
86400 indicates the current time minus 86400 seconds (1 day), and current_date indicates the date of the current day.%H:%i:%s, which contains only the hour, minute, and second but does not contain the date. If the time range spans days, data statistics errors will occur.* |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

Was this page helpful?
You can also Contact sales or Submit a Ticket for help.
Help us improve! Rate your documentation experience in 5 mins.
Feedback