why no rotables?

 avatar
user_0223141589
mysql
a year ago
783 B
1
Indexable
Never
SELECT
  spl.CREATE_DATE as body_create_date,
  spl.name body,
  sl2.COMPLETE_NAME as stock_location,
  sq.QUANTITY as quantity,
  fv.id
FROM
  BIZ.DBT_STG.STG_ODOO_PROD__STOCK_PRODUCTION_LOT spl
  LEFT JOIN BIZ.DBT_STG.STG_ODOO_PROD__STOCK_QUANT sq on sq.lot_id = spl.id
  LEFT JOIN BIZ.DBT_STG.STG_ODOO_PROD__STOCK_LOCATION sl2 on sl2.id = sq.LOCATION_ID
  LEFT JOIN BIZ.DBT_STG.STG_ODOO_PROD__FLEET_VEHICLE fv ON fv.LOT_ID = spl.id
WHERE
  spl.name LIKE '%BDY%'
  --and sq.QUANTITY IS NOT NULL
  AND LTRIM((SPLIT_PART(spl.name, '-', -1)), '0') IN (
    -- EMPTY ZIP_NUMBER IN ROTABLE FLIGHT TABLE
    SELECT
      DISTINCT rf.ZIP_NUMBER
    FROM
      BIZ.DBT_ODOO.ROTABLE_FLIGHTS rf
    WHERE
      rf.SERIAL_NUMBER IS NULL
      AND rf.ZIP_NUMBER IS NOT NULL
  )
order by 1 desc