Single Stat gives no data when using mysql concat , case , or join

Hello, I just tried the single stat (format as table) with a mysql query

select mydb.status
from mydb
where 1=1
AND agentid = 11
AND key = 123

which works fine, but if I use e.g. the concat function, single stat results in no data

select CONCAT( "Status: " , mydb.status )
from mydb
where 1=1
AND agentid = 11
AND key = 123

Just use your first query and set a Prefix in the singlestat panel.

mgrimm, thanks for your reply. As I wrote in my other topic, singlestat does not show the options in your picture. I assume we have different versions.
Anyway, your reply indicates that only static pre/postfixes are possible.

What about the following query, which results in my grafana version also in a ‘no data’ but in mysql-workbench I get the expected result

SELECT
CASE
WHEN  mydb.status  = 0 THEN CONCAT ( mydb.status  , ': logged-out')
WHEN  mydb.status  = 1 THEN CONCAT ( mydb.status  , ': ready')
WHEN  mydb.status  = 2 THEN CONCAT ( mydb.status  , ': busy')
ELSE 'UNDEF'
END AS STATUS
FROM 
mydb

WHERE 1=1
AND agentid = 11
AND DATE(mydb.thetime) =CURDATE()
ORDER BY mydb.thetime DESC LIMIT 1;

What about a connection between two tables , the query replies a varchar not a number. Are only numbers allowed ( cause if the query selects namestab.key it returns data ) ?

SELECT namestab.name
FROM 
mydb , namestab

WHERE 1=1
AND agentid = 11
AND DATE(mydb.thetime) =CURDATE()
AND namestab.key = mydb.agentid
ORDER BY mydb.thetime DESC LIMIT 1;

Is there a documentation for the single stat ?
Does the ‘number-restriction’ apply only to a mysql source or also to other (db-)sources like e.g. oracle ?

Now the Grafana 7 Version: :wink:
You ca do the conversion to text in the query, but you are more flexible if you’re passing just the numbers to grafana and use “value mapping” for text conversion and the “thresholds” for coloring the single stats.

And the stat panel documentation: Stat | Grafana documentation