 WITH cte AS (
         SELECT scrape_data._id,
            scrape_data.is_operational,
            scrape_data.queue_time,
            scrape_data.queue_status_message,
            scrape_data.is_open,
            scrape_data.open_time,
            scrape_data.close_time,
            scrape_data.time_stamp,
            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._id,
    poi.name,
    prices.price,
    cte.is_operational,
    cte.queue_time,
    cte.queue_status_message,
    cte.is_open,
    cte.open_time,
    cte.close_time,
    cte.time_stamp,
    rm.hand_stamp_included,
    rm.bargain_night_included,
    rm.capacity,
    rm.duration,
    poi.summary,
    poi.keywords,
    poi.default_image,
    poi.location,
	poi.location[0] as lattitude,
	poi.location[1] as longitude,
    poi.featured,
    poi.wayfinding_enabled,
    poi.visible_on_map,
    poi.category,
    poi.minimum_height_requirement,
    poi.minimum_unaccompanied_height_requirement,
    poi.maximum_height_requirement,
    poi.minimum_age_requirement,
    poi.minimum_unaccompanied_age_requirement,
    poi.maximum_age_requirement,
    poi.restriction_summary
   FROM cte
     JOIN knoebels.ride_master rm ON cte._id = rm.attractions_dot_io_id
     JOIN knoebels."LZ_attractions_io_poi" poi ON cte._id = poi._id
     LEFT JOIN ( SELECT row_number() OVER (PARTITION BY ride_data_in.ride ORDER BY ride_data_in.time_stamp DESC) AS row_number,
            ride_data_in.time_stamp,
            ride_data_in.ride,
            ride_data_in.price
           FROM knoebels.ride_data_in) prices ON prices.ride = rm.ride AND prices.row_number = 1
  WHERE cte.row_number = 1;