I’m trying to convert a tall table into a long table for use with the Editable Table.
Table name is daily_data, columns are date(pk), parameter_id(pk), value.
I’m looking to pull this data into an editable table where date is the pk and the columns are the different parameters. I also need to get data back out of the editable table so that I can update changes to the daily_data table.
I figured it out. What I’m trying to do is called a Crosstab query.
My daily_data table columns are -
date(pk) parameter_id(pk) value
And I wanted to create a query that would create a table like -
date parameter1 parameter2 paremeter3 parameter…
The query to do this is -
SELECT date,
SUM( IF(parameter_id = 1, value, null) ) as '1',
SUM( IF(parameter_id = 2, value, null) ) as '2',
SUM( IF(parameter_id = 3, value, null) ) as '3'
FROM data_daily GROUP BY date ORDER BY date;