From 0ad83ec42478b494e6b04f3f7fb2e3445d225122 Mon Sep 17 00:00:00 2001 From: Johan Wiklund <33256409+JohanEntur@users.noreply.github.com> Date: Thu, 16 Jan 2020 12:32:14 +0100 Subject: [PATCH] adding new query --- .../list-maxversion-of-all-alternative names | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 alternative-names-review-list/list-maxversion-of-all-alternative names diff --git a/alternative-names-review-list/list-maxversion-of-all-alternative names b/alternative-names-review-list/list-maxversion-of-all-alternative names new file mode 100644 index 0000000..777656e --- /dev/null +++ b/alternative-names-review-list/list-maxversion-of-all-alternative names @@ -0,0 +1,28 @@ +/* Will include active and expired stops and lists all types of alternative names.*/ + +SELECT + sp.version, + sp.to_date, + sp.netex_id, + sp.name_value, + sp.stop_place_type, + an.netex_id, + an.name_value, + an.name_type, + an.name_lang, + tp.name_value, + tp.netex_id, + tp.parent_ref +FROM stop_place sp +INNER JOIN + (SELECT netex_id, MAX(version) as gspv + FROM stop_place + GROUP BY netex_id) groupedsp +ON sp.netex_id = groupedsp.netex_id +AND sp.version = groupedsp.gspv + +left join stop_place_alternative_names sp_an on sp_an.stop_place_id = sp.id +left join alternative_name an on sp_an.alternative_names_id = an.id +left join topographic_place tp on sp.topographic_place_id = tp.id + +where an.netex_id is not null