SELECT loc_table.id AS location_id,
       geom_table.date_of_first_service,
       geom_table.date_of_last_service,
       geom_table.id AS site_id,
       geom_table.version,
       st_x(geom_table.geom_point::geometry) AS lon,
       st_y(geom_table.geom_point::geometry) AS lat
FROM infrastructure.cells AS loc_table
     LEFT JOIN (SELECT site_id,
                       id,
                       version,
                       name,
                       type,
                       status,
                       structure_type,
                       is_cow,
                       date_of_first_service,
                       date_of_last_service,
                       geom_point,
                       geom_polygon
                FROM infrastructure.sites) AS geom_table ON loc_table.site_id = geom_table.id