Changed join to price table to a LEFT JOIN so that I can also keep track of the Alamo restaurant operating hours with the same tables

This commit is contained in:
wes
2024-05-20 13:35:46 -04:00
parent 0ce13cf8a4
commit 1678a2f5a6
4 changed files with 88 additions and 1 deletions
+25
View File
@@ -0,0 +1,25 @@
WITH CTE AS (
SELECT *,
row_number() OVER (PARTITION BY scrape_data._id ORDER BY scrape_data.time_stamp DESC) AS row_number
FROM knoebels."LZ_attractions_io" scrape_data
)
SELECT CTE.time_stamp
,CTE._id
,poi.name
,CTE.is_operational
,CTE.is_open
,CTE.queue_status_message
,last_online.time_stamp AS last_online
FROM CTE
JOIN knoebels."LZ_attractions_io_poi" AS poi ON CTE._id = poi._id
JOIN knoebels.ride_master rm ON CTE._id = rm.attractions_dot_io_id
LEFT JOIN (
SELECT *,
row_number() OVER (PARTITION BY scrape_data._id ORDER BY scrape_data.time_stamp DESC) AS row_number
FROM knoebels."LZ_attractions_io" scrape_data
where is_operational = true and is_open = true
) AS last_online
ON CTE._id = last_online._id and last_online.row_number = 1
WHERE CTE.row_number = 1
AND (CTE.is_operational = false OR (CTE.queue_status_message IS NOT NULL AND CTE.queue_status_message != ''))
ORDER BY name;