How to replace return value in SQL query for display

Hi,
I want to replace a SQL return value with a text based on the value. The value can be ‘0’ or ‘1’ but when the SQL matches to 1, I would like to replace that with a Text value and display that in table.

Like if returned value is 1, then “On_home” else “Off_home”

My query is as below –
select id1,system, duration, state_a, state_z, on_home
FROM tables1
WHERE
Case
on_home = ‘1’ THEN “On_Home”
Else “off_home”
End
ORDER BY system;

I am trying to print them in a table but unfortunately the table is empty.

The SQL query works fine if i use as below
select id1,system, duration, state_a, state_z, on_home
FROM tables1
WHERE on_home = ‘1’
ORDER BY system;

but the issue is that on_home column prints value 1 which I want to be replaced with text as above

Thanks,

you can use value mapping to replace values inside Grafana’s visualization panels:

https://play.grafana.org/d/RWM1gy07k/value-mapping-by-query?orgId=1