# select count(*), t1, t2, t3, t4, t5, t6 from $stb where t1 > $val1 and t1 < $val2 group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0
sqlStr=f"select count(*), t1, t2, t3, t4, t5, t6 from %s where t1 > %d and t1 < %d group by t1, t2, t3, t4, t5, t6 order by t1 asc limit 1 offset 0"%(paraDict["stbName"],val1,val2)
print("====sql:%s"%(sqlStr))
tdSql.query(sqlStr)
tdSql.checkRows(1)
tdSql.checkData(0,0,paraDict["rowsPerTbl"])
tdSql.checkData(0,1,2)
tdSql.checkData(0,2,"tb2")
tdSql.checkData(0,3,"tb2")
tdSql.checkData(0,4,2)
tdSql.checkData(0,5,2)
# select count(*), t3, t4 from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 2 offset 0
sqlStr=f"select count(*), t3, t4 from %s where t2 like '%%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 2 offset 0"%(paraDict["stbName"])
print("====sql:%s"%(sqlStr))
tdSql.query(sqlStr)
tdSql.checkRows(2)
tdSql.checkData(0,0,paraDict["rowsPerTbl"])
tdSql.checkData(0,1,"tb4")
tdSql.checkData(0,2,4)
tdSql.checkData(1,1,"tb3")
tdSql.checkData(1,2,3)
# select count(*) from $stb where t2 like '%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 1
sqlStr=f"select count(*) from %s where t2 like '%%' and t1 > 2 and t1 < 5 group by t3, t4 order by t3 desc limit 1 offset 1"%(paraDict["stbName"])
print("====sql:%s"%(sqlStr))
tdSql.query(sqlStr)
tdSql.checkRows(1)
## TBASE-348
tdSql.error(f"select count(*) from %s where t1 like 1"%(paraDict["stbName"]))
ts0=paraDict["startTs"]
delta=paraDict["tsStep"]
tsu=paraDict["rowsPerTbl"]*delta
tsu=tsu-delta
tsu=tsu+ts0
tb=paraDict["ctbPrefix"]+'0'
# select _wstart, max(c1) from $tb where ts >= $ts0 and ts <= $tsu interval(5m) fill(value, -1) limit 10 offset 1
sqlStr=f"select _wstart, max(c1) from %s where ts >= %d and ts <= %d interval(5m) fill(value, -1) limit 10 offset 1"%(tb,ts0,tsu)
print("====sql:%s"%(sqlStr))
tdSql.query(sqlStr)
tdSql.checkRows(10)
tdSql.checkData(0,0,"18-09-17 09:05:00.000")
tdSql.checkData(0,1,-1)
tdSql.checkData(1,1,1)
tdSql.checkData(9,0,"18-09-17 09:50:00.000")
tdSql.checkData(9,1,5)
tb5=paraDict["ctbPrefix"]+'5'
sqlStr=f"select max(c1), min(c2) from %s where ts >= %d and ts <= %d interval(5m) fill(value, -1, -2) limit 10 offset 1"%(tb5,ts0,tsu)