Version of grafana is 6.7.2
I want to create a table with daily information about production, some information is the max value of a day, other the average, other the last no zero value of a day.
What i have made is this:
SELECT
$__timeGroupAlias(data_hora,$__interval),
max(ocioso_m) as "Alimentador ocioso",
max(descargas) as "Descargas"
FROM operacao_al
WHERE
$__timeFilter(data_hora) AND
al_id = 1
GROUP BY date(data_hora)
ORDER BY $__timeGroup(time,$__interval)
To take the max value of it, but i want to take the last non zero value of a day:
SELECT
$__timeGroupAlias(data_hora,$__interval),
media_carga_ton
FROM operacao_al
WHERE (al_id = 1) and (media_carga_ton > 0) and data_hora in (
select max(data_hora) from operacao_al where al_id = 1 and media_carga_ton > 0 and $__timeFilter(data_hora) group by date(data_hora)
) and $__timeFilter(data_hora)
GROUP BY date(data_hora)
ORDER BY $__timeGroup(time,$__interval)
So i want to select 7 or 30 days and have the date - and the value of every day on a line.
But what is happening is this:
Well i expected date - information on the same line.
So i will apreciate help.