I am trying to solve following problem:
I have a table with timeStamp column and three columns for different types of variables. The columns with values are filled randomly according to the conditions. So it looks like this:
smpl_time float_val num_val str_val
15:31 10 NULL NULL
15:32 NULL 15.4 NULL
15:33 NULL NULL Disabled
What I would like to achieve is a result that would merge all val fields into one column and sorts them according to timeStamp:
smpl_time merge_val
15:31 10
15:32 15.4
15:33 Disabled
So far I have a SELECT just for one val type looking like this (it contains also other field from the table that are common for each entry):
SELECT s.smpl_time AS Time,s.float_val AS Value, e.name AS Severity, m.name AS Status
FROM sample s JOIN channel c ON c.channel_id=s.channel_id JOIN severity e ON
e.severity_id=s.severity_id JOIN status m ON m.status_id=s.status_id WHERE
s.channel_id='id' AND smpl_time BETWEEN TIMESTAMP 'startTime' AND TIMESTAMP 'stopTime';
Does anyone have an idea how to do this or if it is even possible?
Cheers,
Mike