forecast_api/route_sql/build/part_list.sql

27 lines
637 B
SQL

WITH
act As (
SELECT DISTINCT
v6part part
FROM
lgdat.stka
WHERE
(
v6stat = 'A'
OR v6part in ('TWA10203G18B027','TWA10203G18D050','MIH09000G18E001')
)
OR v6type = 'C'
)
,stkm AS (
SELECT
act.part || ' - ' ||rtrim(COALESCE(m.avdes1,p.awdes1)) part
--,COALESCE(m.avgled, p.awgled) glec
FROM
act
LEFT OUTER JOIN lgdat.stkmm m ON
m.avpart = act.part
LEFT OUTER JOIN lgdat.stkmp p ON
p.awpart = act.part
WHERE
substr(COALESCE(m.avgled, p.awgled),1,1) <= '2'
)
select part from stkm