Commit 9f53eef4 authored by Sergio Bruni's avatar Sergio Bruni
Browse files

m

parent 5f503a1c
...@@ -1377,3 +1377,48 @@ group by t.id_station ...@@ -1377,3 +1377,48 @@ group by t.id_station
order by t.id_station order by t.id_station
``` ```
**calcola la mediana x,y,z dai rinex delle stazioni della query precedente**
```
WITH t AS (
select rn.id_network, s.id id_station, count(*) num_rinex from rinex_file r
JOIN rinex_file_network rn on rn.id_rinex_file=r.id
JOIN station s on s.id=r.id_station
JOIN location l on l.id = s.id_location
JOIN coordinates c on c.id=l.id_coordinates AND c.x = -1
-- WHERE s.id=231
group by s.id, rn.id_network
)
select
t2.id_station,
max(s.marker) marker,
t2.id_network,
max(n.name) network_name,
max(t2.num_rinex) num_rinex,
percentile_disc(0.50) within group (order by x_crd_a) median_x,
percentile_disc(0.50) within group (order by y_crd_a) median_y,
percentile_disc(0.50) within group (order by z_crd_a) median_z
FROM rinex_file r
JOIN (
select t.id_station, max(t.id_network) id_network, max(t.num_rinex) num_rinex from (
select id_station, max(num_rinex) num_rinex
from t
GROUP BY id_station
) t1
JOIN
t ON t1.id_station = t.id_station AND t1.num_rinex = t.num_rinex
group by t.id_station
) t2
ON r.id_station=t2.id_station
JOIN rinex_file_network rn ON rn.id_rinex_file=r.id AND rn.id_network=t2.id_network
JOIN station s ON s.id=t2.id_station
JOIN network n ON n.id=t2.id_network
WHERE x_crd_a <> 0 AND x_crd_a IS NOT NULL
and y_crd_a <> 0 AND y_crd_a IS NOT NULL
and z_crd_a <> 0 AND z_crd_a IS NOT NULL
GROUP BY t2.id_station, t2.id_network
```
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