Skip to content

Commit

Permalink
Add quay publicCode & streetAddress to stop_place_newest_version
Browse files Browse the repository at this point in the history
  • Loading branch information
Huulivoide committed Nov 7, 2024
1 parent 597b48b commit e2d81c0
Showing 1 changed file with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
create or replace view stop_place_newest_version as
select distinct on (netex_id) *
from stop_place
order by netex_id, version desc;
DROP VIEW IF EXISTS stop_place_newest_version;

CREATE VIEW stop_place_newest_version AS
SELECT DISTINCT ON (sp.netex_id)
sp.*,
quay.public_code AS quay_public_code,
address_value.items as street_address

FROM stop_place AS sp

INNER JOIN stop_place_quays AS spq ON sp.id = spq.stop_place_id
INNER JOIN quay ON spq.quays_id = quay.id

LEFT JOIN stop_place_key_values AS spkv ON
sp.id = spkv.stop_place_id AND spkv.key_values_key = 'streetAddress'
LEFT JOIN value_items AS address_value ON spkv.key_values_id = address_value.value_id

ORDER BY netex_id ASC, version DESC

0 comments on commit e2d81c0

Please sign in to comment.