forecast_api/route_sql/part_list.sql

23 lines
507 B
MySQL
Raw Normal View History

WITH
act As (
SELECT DISTINCT
v6part part
FROM
lgdat.stka
WHERE
v6stat = 'A'
)
,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