CTE (с) ниже используется для имитации ваших двух таблиц:
With Temp (City, value, Mdate) as (SELECT 'C1', 19.6, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C3', 10.6, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C3', 12, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C2', 10.1, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C2', 18, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C2', 10, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C1', 21.6, to_date('2017-10-02 20:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C1', 10.6, to_date('2017-10-02 20:01','YYYY-MM-DD HH24:MI') FROM DUAL),
Humidity (City, value, mDate) as (SELECT 'C1', 60, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C3', 70, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C3', 62, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C2', 67, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C2', 68, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C2', 70, to_date('2017-10-02 19:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C1', 71.6, to_date('2017-10-02 20:01','YYYY-MM-DD HH24:MI') FROM DUAL UNION ALL
SELECT 'C1', 70.6, to_date('2017-10-02 20:01','YYYY-MM-DD HH24:MI') FROM DUAL)
--Now this is the query to coorlate the two values between two dates using the two CTE's above.
SELECT T.City, Corr(T.Value, H.Value) corr
FROM TEMP T
INNER JOIN HUMIDITY H
on T.City = H.City
and T.mDate = H.mDate
WHERE T.mDate between to_date('2017-10-01','YYYY-MM-DD') and to_date('2017-11-02','YYYY-MM-DD')
GROUP BY T.City
Дает нам:
+------+--------------------------------------------+
| City | Corr |
+------+--------------------------------------------+
| C2 | 0 |
| C1 | -0.272343645393387267052058460609147833569 |
| C3 | 0 |
+------+--------------------------------------------+