sleep 100 sql connect $db = testdb sql use $db print "test tb1" sql select last(ts) from tb1 if $rows != 1 then return -1 endi if $data00 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi sql select last(f1) from tb1 if $rows != 1 then return -1 endi if $data00 != 6 then print $data00 return -1 endi sql select last(*) from tb1 if $rows != 1 then return -1 endi if $data00 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi if $data01 != 6 then return -1 endi if $data02 != 5.000000000 then print $data02 return -1 endi if $data03 != 3 then return -1 endi if $data04 != @70-01-01 07:59:57.000@ then return -1 endi sql select last(tb1.*,ts,f4) from tb1 if $rows != 1 then return -1 endi if $data00 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi if $data01 != 6 then return -1 endi if $data02 != 5.000000000 then print $data02 return -1 endi if $data03 != 3 then return -1 endi if $data04 != @70-01-01 07:59:57.000@ then return -1 endi if $data05 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi if $data06 != @70-01-01 07:59:57.000@ then return -1 endi print "test tb2" sql select last(ts) from tb2 if $rows != 1 then return -1 endi if $data00 != @21-05-11 10:11:15.000@ then print $data00 return -1 endi sql select last(f1) from tb2 if $rows != 1 then return -1 endi if $data00 != -6 then print $data00 return -1 endi sql select last(*) from tb2 if $rows != 1 then return -1 endi if $data00 != @21-05-11 10:11:15.000@ then print $data00 return -1 endi if $data01 != -6 then return -1 endi if $data02 != -7.000000000 then print $data02 return -1 endi if $data03 != -8 then return -1 endi if $data04 != @70-01-01 07:59:56.999@ then if $data04 != @70-01-01 07:59:57.-01@ then return -1 endi endi sql select last(tb2.*,ts,f4) from tb2 if $rows != 1 then return -1 endi if $data00 != @21-05-11 10:11:15.000@ then print $data00 return -1 endi if $data01 != -6 then return -1 endi if $data02 != -7.000000000 then print $data02 return -1 endi if $data03 != -8 then return -1 endi if $data04 != @70-01-01 07:59:56.999@ then if $data04 != @70-01-01 07:59:57.-01@ then return -1 endi endi if $data05 != @21-05-11 10:11:15.000@ then print $data00 return -1 endi if $data06 != @70-01-01 07:59:56.999@ then if $data04 != @70-01-01 07:59:57.-01@ then return -1 endi endi print "test tbd" sql select last(*) from tbd if $rows != 1 then return -1 endi if $data00 != @21-05-11 10:12:29.000@ then print $data00 return -1 endi if $data01 != NULL then return -1 endi if $data02 != NULL then print $data02 return -1 endi if $data03 != NULL then return -1 endi if $data04 != NULL then return -1 endi print "test tbe" sql select last(*) from tbe if $rows != 0 then return -1 endi print "test stable" sql select last(ts) from st2 if $rows != 1 then return -1 endi if $data00 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi sql select last(f1) from st2 if $rows != 1 then return -1 endi if $data00 != 6 then print $data00 return -1 endi sql select last(*) from st2 if $rows != 1 then return -1 endi if $data00 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi if $data01 != 6 then return -1 endi if $data02 != 37.000000000 then print $data02 return -1 endi if $data03 != 27 then return -1 endi if $data04 != @70-01-01 07:59:57.000@ then return -1 endi sql select last(st2.*,ts,f4) from st2 if $rows != 1 then return -1 endi if $data00 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi if $data01 != 6 then return -1 endi if $data02 != 37.000000000 then print $data02 return -1 endi if $data03 != 27 then return -1 endi if $data04 != @70-01-01 07:59:57.000@ then return -1 endi if $data05 != @21-05-12 10:10:12.000@ then print $data00 return -1 endi if $data06 != @70-01-01 07:59:57.000@ then return -1 endi sql select last(*) from st2 group by id if $rows != 5 then return -1 endi if $data00 != @21-05-12 10:10:12.000@ then return -1 endi if $data01 != 6 then return -1 endi if $data02 != 5.000000000 then print $data02 return -1 endi if $data03 != 21 then return -1 endi if $data04 != @70-01-01 07:59:57.000@ then return -1 endi if $data05 != 1 then return -1 endi if $data10 != @21-05-11 10:12:23.000@ then return -1 endi if $data11 != 22 then return -1 endi if $data12 != 23.000000000 then print $data02 return -1 endi if $data13 != -8 then return -1 endi if $data14 != @70-01-01 07:59:57.996@ then if $data14 != @70-01-01 07:59:58.-04@ then print $data14 return -1 endi endi if $data15 != 2 then return -1 endi if $data20 != @21-05-10 10:12:24.000@ then return -1 endi if $data21 != 24 then return -1 endi if $data22 != 8.000000000 then print $data02 return -1 endi if $data23 != 25 then return -1 endi if $data24 != @70-01-01 07:59:56.996@ then if $data24 != @70-01-01 07:59:57.-04@ then return -1 endi endi if $data25 != 3 then return -1 endi if $data30 != @21-05-11 10:12:25.000@ then return -1 endi if $data31 != 26 then return -1 endi if $data32 != 17.000000000 then print $data02 return -1 endi if $data33 != 27 then return -1 endi if $data34 != @70-01-01 07:59:55.996@ then if $data34 != @70-01-01 07:59:56.-04@ then return -1 endi endi if $data35 != 4 then return -1 endi if $data40 != @21-05-11 10:12:29.000@ then return -1 endi if $data41 != 36 then return -1 endi if $data42 != 37.000000000 then print $data02 return -1 endi if $data43 != 35 then return -1 endi if $data44 != @70-01-01 07:59:55.995@ then if $data44 != @70-01-01 07:59:56.-05@ then return -1 endi endi if $data45 != 5 then return -1 endi print "test tbn" sql create table tbn (ts timestamp, f1 int, f2 double, f3 binary(10), f4 timestamp) sql insert into tbn values ("2021-05-09 10:10:10", 1, 2.0, '3', -1000) sql insert into tbn values ("2021-05-10 10:10:11", 4, 5.0, NULL, -2000) sql insert into tbn values ("2021-05-12 10:10:12", 6,NULL, NULL, -3000) sql insert into tbn values ("2021-05-13 10:10:12", NULL,NULL, NULL,NULL) sql select last(*) from tbn; if $rows != 1 then return -1 endi if $data00 != @21-05-13 10:10:12.000@ then print $data00 return -1 endi if $data01 != 6 then return -1 endi if $data02 != 5.000000000 then print $data02 return -1 endi if $data03 != 3 then return -1 endi if $data04 != @70-01-01 07:59:57.000@ then return -1 endi