
Here $Bundesland and $Klassenstufe are being interpolated differently. Example:

Why is that?
The queries from which each variable comes are essentially analogous, i.e. equivalent, up to identifier names.
However, the column type of Bundesland in the database is varchar(255),
whereas the Klassenstufe column is of type integer.
I cannot simply cast:
$Bundesland::text
because I want to use “All” option as well.
But I would like to know why the single values are interpolated differently. Thanks!
that is indeed odd. you need to add single quotes to the '$Bundesland'
Grafana doesn’t know by itself that Bundesland
is a text (string), so it doesn’t add quotes around it. But SQL needs quotes around text values like 'Saarland'
.
WHERE bundesland IN (${Bundesland:sqlstring})
This will make Grafana add quotes around each value, like:
WHERE bundesland IN ('Saarland')
try this
WHERE bundesland IN (${Bundesland:sqlstring})
AND schuljahr = ‘${CURRENT_SCHULJAHR}’
AND klassenstufe IN (${Klassenstufe})
- Strings (like
Bundesland
) will have quotes → 'Saarland'
- Numbers (like
Klassenstufe
) will not have quotes → 3
Thanks to both of you!
Just single quotes doesn’t work with the “All” option, but ${Bundesland:sqlstring} did the trick
2 Likes