      INSERT INTO grab_inspections (
        `listing_id`,
        `sales_inspection_id`,
        `show`,
        `insp_date`,
        `start_time`,
        `end_time`,
        `changed_at`
      )

      SELECT
        `grab_listings`.`id` AS `listing_id`,
        `inspection`.`inspectionid_pk` AS `sales_inspection_id`,
        GROUP_CONCAT(`open_time_reason`.`reason_desc`) LIKE "%Open%" AS `show`,
        `inspection`.`insp_date`,
        `inspection`.`start_time`,
        `inspection`.`end_time`,
        GREATEST(
          COALESCE(`inspection`.`ts`, 0),
          COALESCE(`inspection_details`.`ts`, 0),
          COALESCE(`open_time_reason`.`ts`, 0)
        ) AS `changed_at`

      FROM `inspection`

      LEFT JOIN `grab_inspections`
      ON `grab_inspections`.`sales_inspection_id` = `inspection`.`inspectionid_pk`

      LEFT JOIN `grab_listings`
      ON `grab_listings`.`sales_listing_id` = `inspection`.`listingid_fk`

      LEFT JOIN `inspection_details`
      ON `inspection`.`inspectionid_pk` = `inspection_details`.`inspectionid_fk`

      LEFT JOIN `open_time_reason`
      ON `inspection_details`.`reasonid_fk` = `open_time_reason`.`reasonid_pk`

      WHERE `grab_inspections`.`changed_at` IS NULL
      OR GREATEST(
        COALESCE(`inspection`.`ts`, 0),
        COALESCE(`inspection_details`.`ts`, 0),
        COALESCE(`open_time_reason`.`ts`, 0)
      ) > `grab_inspections`.`changed_at`
      GROUP BY inspectionid_pk

      ON DUPLICATE KEY UPDATE
        `listing_id` = VALUES(`listing_id`),
        `sales_inspection_id` = VALUES(`sales_inspection_id`),
        `show` = VALUES(`show`),
        `insp_date` = VALUES(`insp_date`),
        `start_time` = VALUES(`start_time`),
        `end_time` = VALUES(`end_time`),
        `changed_at` = VALUES(`changed_at`)            
