I Can't use variable inside a function?

I’m trying use a variable inside a MAX funciont but I Can’t

SELECT
    Distance, 
    MAX(CASE WHEN Driver = 'VER' THEN Speed END) AS Speed_VER,
    MAX(CASE WHEN Driver = 'NOR' THEN Speed END) AS Speed_NOR
FROM
    telemetria
WHERE
    (Lap = $volta  AND Country = 'Brazil' AND Driver = $driver01)
GROUP BY
    Distance
ORDER BY
    Distance;

Somebody could help me?

Welcome @rgustavo32s

I am not seeing that variable being used in the MAX function

I Would Like use in ‘VER’ place, but doesn’t work

MAX(CASE WHEN Driver = ${driver01:singlequote} THEN Speed END) AS Speed_VER,
    MAX(CASE WHEN Driver = ${driver02:singlequote} THEN Speed END) AS Speed_NOR

but then your query wont make sense as the where clause uses

Driver = $driver01

Sorry, where clause was a test.
But doesn’t wor, Take a look in the prints

look at the error and review your code carefully , you have a syntax error

Work!!

Thank you very much!!

1 Like

sei il benvenuto amico! :racing_car::racing_car:

I’m trying to make dynamic panels in Grafana from CSV files but I can’t link variables to the panel. Do you know if with CSV files you can’t use variables?