-------------------------------
-- Querying the weather data --
-------------------------------

-- Get currently operating stations
SELECT agent, network, start_date, end_date, station_name,
    lat_dec_deg, long_dec_deg
FROM weather.station_dim
WHERE end_date IS NULL AND
    start_date <= to_date('2015-01-01', 'yyyy-mm-dd')
ORDER BY start_date;

-- 1 agent per network and vice versa?
SELECT COUNT(DISTINCT agent) as agents, network
FROM weather.station_dim
GROUP BY network
ORDER BY agents DESC;

-- Get data from station 2006
SELECT record_no, station, temp_date, temp_time, tmax_c, tmin_c,
    tgmin, tmean, rhmean
FROM weather.temperature_fact
WHERE station = 2006 AND
    temp_date >= to_date('2016-01-01', 'yyyy-mm-dd') AND
    temp_date <  to_date('2019-01-01', 'yyyy-mm-dd')
ORDER BY temp_date, temp_time;
