MySQL "case" function is not working correctly

I have some metrics data, this metrics data generated under differents testing “scenario(s)” and I need to compare metrics data from differents “scenarios” on single graph. Due each data records for each “scenario(s)” have it own unique timestamp (and differences between them may be days or weeks, this is reason why timeshift option is can not be used), I created simple query, that generate timestamp for each “scenario(s)” starting from now() and each next records under it will have now()+1 minute. This query working correctly in MySQL Workbench, but on grafana all records always have same timestamp.

Is right now Grafana do not support such queries or I should add / update something to make it work correctly?

Below can be found query and some screenshots.
MySQL query:

SELECT
UNIX_TIMESTAMP(STR_TO_DATE(CASE PERFORMANCE_SCENARIO.name
WHEN @currencyScenario THEN @currentRecordTimestamp:=@currentRecordTimestamp + interval 1 minute
ELSE @currentRecordTimestamp:=TIMESTAMP(CURDATE())
END, ‘%Y-%m-%d %H:%i:%s’)) AS time_sec,
CASE PERFORMANCE_SCENARIO.name
WHEN @currencyScenario THEN @currentRecordTimestamp:=@currentRecordTimestamp + interval 1 minute
ELSE @currentRecordTimestamp:=TIMESTAMP(CURDATE())
END as generated_timestamp,
PERFORMANCE_AUDIT_RECORD.runtime as value,
@currencyScenario:=PERFORMANCE_SCENARIO.name AS metric
FROM
PERFORMANCE_AUDIT
INNER JOIN
PERFORMANCE_SCENARIO ON styx.PERFORMANCE_SCENARIO.id = PERFORMANCE_AUDIT.scenario_id
INNER JOIN
PERFORMANCE_AUDIT_RECORD ON PERFORMANCE_AUDIT_RECORD.performance_audit_id = PERFORMANCE_AUDIT.id
WHERE
PERFORMANCE_SCENARIO.id IN (478 , 438)

MySQL query results on workbench:
mysql_workbench

Grafana query results:

Hi,

Referring to the Grafana MySql documentation, please try and group by your time and metric and order by time. Not sure that such advanced queries are supported though and the actual sql statemnet executed aren’t the same as when you run it in workbench.

Marcus

Thanks for reply, I will try to do as you said and give you know if this will resolve my issue.