i want to join table, and i have 2 table like
Table : Suhu
ID_ROOM | SUHU_MIN | SUHU_MAX
----------------------------------
1 10 15
1 12 20
1 15 25
1 20 22
Table : RH
ID_ROOM | RH_MIN | RH_MAX
----------------------------------
1 11 19
1 14 18
and I want output like this :
ID_ROOM | SUHU_MIN | SUHU_MAX | RH_MIN | RH_MAX
----------------------------------------------------
1 10 15 11 19
1 12 20 14 18
1 15 25 NULL NULL
1 20 22 NULL NULL
I have used left join, and the result is like this
SELECT S.suhu_min, S.suhu_max, R.rh_min, R.rh_max
FROM SUHU S LEFT JOIN RH R ON S.ID_ROOM = R.ID_ROOM;
ID_ROOM | SUHU_MIN | SUHU_MAX | RH_MIN | RH_MAX
----------------------------------------------------
1 10 15 11 19
1 12 20 14 18
1 15 25 11 19
1 20 22 14 18
2
Answers
I assume you want to compare min_value and max_value
Here is the SQL query that you can use
But there must be a logic that differs one row from others
I sorted the rows by _MIN columns per ID_Room and joined two tables accordingly