Blobonator Blobonator - 1 year ago 39
SQL Question

SQL: Split Dataset into two columns

I have a table like this:

Now I want a table like this with a SELECT command:

time1 and value1 is from the data with c_id=4,
time2 and value2 is from the data with c_id=5

Is it possible to create a SELECT command to do that?

I hope you can help


Yiu can use an inner join

select a.time as time1, a.value as value1, b.time as time2, b.value as value2
from my_table as a 
inner join my_table as b on a.time = b.time
and a.c_id= 4
and b.c_id= 5;