针对特殊下发可通过下面的sql进行构建(需要数据源行数和下发地址行数匹配):
WITH TMP AS ( SELECT CodeNO, Model, ShortCode, ModelCode FROM PM_CodeInfo WHERE CodeNO = 'B228ALNA3C01437' AND linecode = 'AL' ), Formula AS (SELECT 10+row_number ( ) OVER ( ORDER BY StationCode, StationSeq ) AS IDX, FormulaNo FROM PM_FormulaInfo WHERE model = ( SELECT Model FROM TMP ) AND LineCode = 'AL') SELECT 1 AS IDX, ModelCode AS FormulaNo FROM TMP UNION SELECT 2 AS IDX, CodeNO AS FormulaNo FROM TMP UNION SELECT 3 AS IDX, ShortCode AS FormulaNo FROM TMP UNION SELECT 4 AS IDX, Model AS FormulaNo FROM TMP UNION ALL ( SELECT IDX, FormulaNo FROM Formula ) ORDER BY IDX;
如果需要数据源行数和下发地址行数不匹配,需要构建指定标识的sql:
标签:TMP,IDX,UNION,下发,sql,FormulaNo,配方,SELECT From: https://www.cnblogs.com/egreen/p/16954603.html