sql_error select count(*) from m_fl_tb0 interval(1s) fill(prev);
print =============== clear
sql drop database $db
sql show databases
if $rows != 0 then
print =====================> aggregation + arithmetic + fill
#sql select avg(cpu_taosd) - first(cpu_taosd) from dn1 where ts<'2020-11-13 11:00:00' and ts>'2020-11-13 10:50:00' interval(10s) fill(value, 99)
#sql select count(*), first(k), avg(k), avg(k)-first(k) from tm0 where ts>'2020-1-1 1:1:1' and ts<'2020-1-1 1:02:59' interval(10s) fill(value, 99);
#sql select count(*), first(k), avg(k), avg(k)-first(k) from tm0 where ts>'2020-1-1 1:1:1' and ts<'2020-1-1 1:02:59' interval(10s) fill(NULL);
print =====================> td-2060
sql create table m1 (ts timestamp, k int ) tags(a int);
sql create table if not exists tm0 using m1 tags(1);
sql insert into tm0 values('2020-1-1 1:1:1', 1);
sql insert into tm0 values('2020-1-1 1:1:2', 2);
sql insert into tm0 values('2020-1-1 1:1:3', 3);
sql insert into tm0 values('2020-1-1 1:2:4', 4);
sql insert into tm0 values('2020-1-1 1:2:5', 5);
sql insert into tm0 values('2020-1-1 1:2:6', 6);
sql insert into tm0 values('2020-1-1 1:3:7', 7);
sql insert into tm0 values('2020-1-1 1:3:8', 8);
sql insert into tm0 values('2020-1-1 1:3:9', 9);
sql insert into tm0 values('2020-1-1 1:4:10', 10);
sql select max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90,89,88,87,86,85);
if $rows != 8 then
return -1
endi
if $data00 != @20-01-01 01:01:00.000@ then
return -1
endi
if $data01 != 2.000000000 then
return -1
endi
if $data02 != 2.000000000 then
return -1
endi
if $data03 != -2.000000000 then
return -1
endi
if $data10 != @20-01-01 01:01:10.000@ then
return -1
endi
if $data11 != 99.000000000 then
return -1
endi
if $data12 != 91.000000000 then
return -1
endi
if $data13 != 90.000000000 then
return -1
endi
if $data60 != @20-01-01 01:02:00.000@ then
return -1
endi
if $data61 != 2.000000000 then
return -1
endi
if $data62 != 2.000000000 then
return -1
endi
if $data63 != -2.000000000 then
return -1
endi
if $data70 != @20-01-01 01:02:10.000@ then
return -1
endi
if $data71 != 99.000000000 then
return -1
endi
if $data72 != 91.000000000 then
return -1
endi
if $data73 != 90.000000000 then
return -1
endi
sql select first(k)-avg(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(NULL);
if $rows != 8 then
return -1
endi
if $data00 != @20-01-01 01:01:00.000@ then
return -1
endi
if $data01 != -1.000000000 then
return -1
endi
if $data02 != -2.000000000 then
return -1
endi
if $data10 != @20-01-01 01:01:10.000@ then
return -1
endi
if $data11 != NULL then
return -1
endi
if $data12 != NULL then
return -1
endi
sql select max(k)-min(k),last(k)-first(k),0-spread(k) from tm0 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 4:2:15' interval(500a) fill(value, 99,91,90,89,88,87,86,85) order by ts asc;
if $rows != 21749 then
return -1
endi
sql select max(k)-min(k),last(k)-first(k),0-spread(k),count(1) from m1 where ts>='2020-1-1 1:1:1' and ts<='2020-1-1 1:2:15' interval(10s) fill(value, 99,91,90,89,88,87,86,85) order by ts asc;