Multiple Metric in SQL

Hi Team,

Maria Db Table

Time | Person | Score
1 | A | 110
1 | B | 110
1 | A | 10
1 | C | 20
1 | A | 210
1 | D | 50

I would like to have timestamp in X-axis and each Person’s Score in Y-Axis .(multiple lines)

How to achieve multiple metric using MariaDb.

I have tried Templating Variables for Person.
Variables:
$Person SELECT DISTINCT Person from Table1;

SQL
SELECT UNIX_TIMESTAMP(Timestamp) as time_sec, Score as value, $Person as metric FROM Table1 where Person IN ($Person)

if I choose multiple persons, the metric does not scale up with multiple values.
Kindly suggest an approch

Thanks & Regards.
Ganeshiva

Hi,

You don’t want to use the variable for metric column in select, you should use the person table and then you should group by timestamp and person and order by timestamp.

I’m not going to help you write the query. There are huge number of topics here showing you how to do this. Also refer to documentation.

Good luck

Marcus