Commit c6404fc9 authored by Sergio Bruni's avatar Sergio Bruni
Browse files

m

parent dd8a965d
......@@ -1178,7 +1178,7 @@ having count(*) = 2
**"Querone" ultima versione**
**"Querone" versione che separa le stazioni se provenienti da diverse reti**
```
SELECT
......@@ -1260,3 +1260,94 @@ ORDER BY
w1.network_name, w1.station_code, w1.reference_date ASC
```
**"Querone" versione che accomuna le stazioni provenienti da diverse reti**
```
SELECT
w1.network_name,
CONCAT(marker, monument_num, receiver_num, country_code) AS station,
w1.reference_date AS day,
w1.receiver_type,
w1.receiver_number,
UPPER(w1.receiver_version) AS receiver_version,
w1.antenna_number,
w1.antenna_type,
w1.antenna_dome,
w1.antenna_delta_h,
w1.antenna_delta_e,
w1.antenna_delta_n
FROM
(
SELECT
n.name AS network_name,
n.id AS network_id,
s.id as station_id,
s.marker,
s.monument_num,
s.receiver_num,
s.country_code,
r.reference_date,
UPPER(r.receiver_type) AS receiver_type,
r.receiver_number,
UPPER(r.receiver_version) AS receiver_version,
r.antenna_number,
r.antenna_type,
r.antenna_delta_h,
r.antenna_delta_e,
r.antenna_delta_n,
r.antenna_dome,
-- LEAD(n.id) OVER (ORDER BY marker, reference_date DESC) AS prev_network_id,
LEAD(s.id) OVER (ORDER BY s.id, reference_date DESC)
AS prev_station_id,
LEAD(r.receiver_number) OVER (ORDER BY s.id, reference_date DESC)
AS prev_receiver_number,
LEAD(upper(r.receiver_type)) OVER (ORDER BY s.id, reference_date DESC)
AS prev_receiver_type,
LEAD(upper(r.receiver_version)) OVER (ORDER BY s.id, reference_date DESC)
AS prev_receiver_version,
LEAD(r.antenna_number) OVER (ORDER BY s.id, reference_date DESC)
AS prev_antenna_number,
LEAD(r.antenna_type) OVER (ORDER BY marker, reference_date DESC)
AS prev_antenna_type,
LEAD(r.antenna_delta_h) OVER (ORDER BY s.id, reference_date DESC)
AS prev_antenna_delta_h,
LEAD(r.antenna_delta_e) OVER (ORDER BY s.id, reference_date DESC)
AS prev_antenna_delta_e,
LEAD(r.antenna_delta_n) OVER (ORDER BY s.id, reference_date DESC)
AS prev_antenna_delta_n,
LEAD(r.antenna_dome) OVER (ORDER BY s.id, reference_date DESC)
AS prev_antenna_dome
FROM rinex_file r
JOIN station s ON s.id=r.id_station
JOIN rinex_file_network rn ON rn.id_rinex_file=r.id -- AND sn.id_network = rn.id_network
JOIN network n ON n.id=rn.id_network
WHERE
n.id IN (39, 40)
-- and s.id=88
AND r.status = 1
-- and date_part('YEAR', r.reference_date) = 2019
-- and r.reference_date < '9999-01-01'
ORDER BY reference_date DESC
) AS W1
WHERE
-- w1.network_id IS DISTINCT FROM w1.prev_network_id
w1.station_id IS DISTINCT FROM w1.prev_station_id
OR w1.receiver_type IS DISTINCT FROM w1.prev_receiver_type
OR w1.receiver_number IS DISTINCT FROM w1.prev_receiver_number
OR w1.receiver_version IS DISTINCT FROM w1.prev_receiver_version
OR w1.antenna_number IS DISTINCT FROM w1.prev_antenna_number
OR w1.antenna_type IS DISTINCT FROM w1.prev_antenna_type
OR w1.antenna_delta_h IS DISTINCT FROM w1.prev_antenna_delta_h
OR w1.antenna_delta_e IS DISTINCT FROM w1.prev_antenna_delta_e
OR w1.antenna_delta_n IS DISTINCT FROM w1.prev_antenna_delta_n
OR w1.antenna_dome IS DISTINCT FROM w1.prev_antenna_dome
ORDER BY
w1.marker,
w1.monument_num,
w1.receiver_num,
w1.country_code,
w1.reference_date ASC
```
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment