grafana 图表必须有时间,当date是字符串时,需要转换成时间戳
select unix_timestamp(DATE_FORMAT(date,'%Y-%m-%d %H:%M:%s')) as time,
sum(count)
from default.test
where date>='$from' and date<='$to'
and field in (${field:sqlstring})
当聚合字段不确定时,可以做成变量
select substring(date,1,10) as '日期'${group:raw},
sum(count)
from sauron.pos_weigh_scan_statistics
where date>='$from' and date<='$to'
and field in (${field:sqlstring})
group by date${group:raw}
order by date desc limit 100