Function | Syntax | Description |
compare(x,n) | Compare the calculation result of the current time period with the calculation result of a time period n seconds before: | |
| compare(x,n1,n2,n3...) | Compare the calculation result of the current time period with the calculation results of time periods n1, n2, and n3 seconds before: |
| compare(x,n,time) | Compares the change trend of x over time in the current time period with that in the time period n seconds ago, where time is the time column corresponding to the change trend of x. |
| compare(x,n1,n2,n3...,time) | Compares the change trend of x over time in the current time period with those in the time periods n1 seconds, n2 seconds, and n3 seconds ago, where time is the time column corresponding to the change trend of x. |
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...)
compare(x,n,time)
compare(x,n1,n2,n3...,time)
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). |
time | This parameter is required if the change trend of x over time is compared. Time is the time column corresponding to the change trend of x and must be of the timestamp type. |
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.* |SELECTcompare[1] AS today, compare[2] AS yesterday, timeFROM(SELECTcompare(PV, 86400, time) AS compare, timeFROM(SELECTcount(*) AS PV, histogram(__TIMESTAMP__, INTERVAL 5 MINUTE) AS timeGROUP BYtime))

피드백