I have the following MSSQL query in a Graph Panel
SELECT $__timeGroup(PO.DataCadastro, '24h') as time, POItem.Status, PO.CodigoRegional, COUNT(POItem.LinhaPO) as Quantidade
FROM PO INNER JOIN POItem ON POItem.CodigoPO = PO.Codigo
WHERE PO.CodigoRegional IN ($Regional)
AND $__timeFilter(PO.DataCadastro)
GROUP BY $__timeGroup(PO.DataCadastro, '24h'), POItem.Status, PO.CodigoRegional
My problem is when I try to use two fields(POItem.Status, PO.CodigoRegional) in Group by clause.
Error: “Value column must have numeric datatype, column: CodigoRegional type: string”
Both fileds are string type.
Does anyone knows how to do it work?
Which version are you using??
I have a question, you need to graph the POItem.Status and PO.CodigoRegional??? or just “COUNT (POItem.LinhaPO)”??? because I think it is not necessary to put them in the SELECT even if you need it in the GROUP BY
then excuse me if I get you wrong, but try this:
SELECT $__timeGroup(PO.DataCadastro, '24h') as time, COUNT(POItem.LinhaPO) as Quantidade
FROM PO INNER JOIN POItem ON POItem.CodigoPO = PO.Codigo
WHERE PO.CodigoRegional IN ($Regional)
AND $__timeFilter(PO.DataCadastro)
GROUP BY $__timeGroup(PO.DataCadastro, '24h'), POItem.Status, PO.CodigoRegional
I need to use both, I need two metric(Status and CodigoRegional)
Then you’ll need to convert your string value to numeric.
I need to do something like this
That’s not supported. The closest you can come is to use X-Axis mode=series, see documentation, and something like this:
SELECT
$__timeGroup(PO.DataCadastro, '24h') as time,
POItem.Status as metric,
COUNT(POItem.LinhaPO) as value
..
GROUP BY
$__timeGroup(PO.DataCadastro, '24h'),
POItem.Status.
I’m already using X-Axis mode=series with one field in Group by and it works, but I wanted to use these two fields. Anyway thanks for your help.