sql insert into tb1 values ('2022-07-10 16:31:00', 1, '1');
sql insert into tb1 values ('2022-07-10 16:32:00', 2, '2');
sql insert into tb1 values ('2022-07-10 16:33:00', 3, '3');
sql insert into tb1 values ('2022-07-10 16:34:00', 4, '4');
sql select * from (select ts,TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),timediff(TIMETRUNCATE(ts,1d),TIMETRUNCATE(ts,1h),1h) as td from tb1 where ts >='2022-06-01 00:00:00' and ts <=' 2022-11-3 23:59:59' ) t where td >12;
if $rows != 4 then
return -1
endi
if $data00 != @22-07-10 16:31:00.000@ then
return -1
endi
if $data10 != @22-07-10 16:32:00.000@ then
return -1
endi
if $data20 != @22-07-10 16:33:00.000@ then
return -1
endi
if $data30 != @22-07-10 16:34:00.000@ then
return -1
endi
sql select * from tb1 where ts > '2022-07-10 16:32:00';
if $rows != 2 then
return -1
endi
if $data00 != @22-07-10 16:33:00.000@ then
return -1
endi
if $data10 != @22-07-10 16:34:00.000@ then
return -1
endi
sql select * from tb1 where ts + 1 > '2022-07-10 16:32:00';
if $rows != 3 then
return -1
endi
if $data00 != @22-07-10 16:32:00.000@ then
return -1
endi
if $data10 != @22-07-10 16:33:00.000@ then
return -1
endi
if $data20 != @22-07-10 16:34:00.000@ then
return -1
endi
sql select * from tb1 where '2022-07-10 16:32:00' > timestamp '2022-07-10 16:31:59';
if $rows != 4 then
return -1
endi
if $data00 != @22-07-10 16:31:00.000@ then
return -1
endi
if $data10 != @22-07-10 16:32:00.000@ then
return -1
endi
if $data20 != @22-07-10 16:33:00.000@ then
return -1
endi
if $data30 != @22-07-10 16:34:00.000@ then
return -1
endi
sql select case f1 when '1' then 1 when '2022-07-10 16:32:00' then '2' end from tb1;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != NULL then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case ts when '2022-07-10 16:31:00' then 1 when '2022-07-10 16:32:00' then '2' end from tb1;
if $rows != 4 then
return -1
endi
if $data00 != 1 then
return -1
endi
if $data10 != 2 then
return -1
endi
if $data20 != NULL then
return -1
endi
if $data30 != NULL then
return -1
endi
sql select case '2022-07-10 16:31:00' when ts then 1 when 2022 then '2' else 3 end from tb1;