请将以下TeraData查询转换为Hive ..我是Hive的新手并且无法转换它。 请指导如何转换案例..当teradata进入Hive时。 在转换时......我遇到了很多错误
SELECT
MLOC.MATL_LOC_ID,
MLOC.MATL_ID,
MLOC.LOC_PRTY_ID,
MLOC.SRC_SYS_CD,
MLOC.PLNT_CD,
MLOC.PRCTR_SGMNT_ID,
MLOC.PRCTR_CD,
MLOC.CC_SGMNT_ID,
MLOC.CC_CD,
MLOC.CNTL_AREA_NUM,
MLOC.DFLT_MATL_PLNT_DESC,
MLOC.VALUATION_CATEGORY_CD,
MLOC.DMND_PLNT_CD,
MLOC.SFTY_STK_QTY,
MLOC.MATL_ABC_CLSN_CD MATL_ABC_CLSN_CD_ORIG,
case when (MATL_ABC_CLSN_CD is null or trim(MATL_ABC_CLSN_CD)='' or MATL_ABC_CLSN_CD='#') then 'NOT DEFINED'
when MATL_ABC_CLSN_CD not in ('A','B','C','D','Z') then 'C'
else MATL_ABC_CLSN_CD end MATL_ABC_CLSN_CD_DERV,
case when src_sys_cd in ('M07','M02','M09','M18','M22','M25','M27') and MATL_ABC_CLSN_CD_DERV = 'A' then '98%'
when src_sys_cd in ('M07','M02','M09','M18','M22','M25','M27') and MATL_ABC_CLSN_CD_DERV in ('B','C','D','Z') then '96%'
when src_sys_cd in ('M17','M03','M21') and MATL_ABC_CLSN_CD_DERV = 'A' then '99%'
when src_sys_cd in ('M17','M03','M21') and MATL_ABC_CLSN_CD_DERV in ('B','C','D') then '98%'
when src_sys_cd in ('M01','M10') and MATL_ABC_CLSN_CD_DERV = 'A' then '99%'
when src_sys_cd in ('M01','M10') and MATL_ABC_CLSN_CD_DERV in ('B','C','D') then '97%'
when src_sys_cd in ('M26','M29') and MATL_ABC_CLSN_CD_DERV = 'A' then '96%'
when src_sys_cd in ('M26','M29') and MATL_ABC_CLSN_CD_DERV in ('B','C','D') then '94%'
else 'NOT DEFINED' end ITEM_SERV_LVL_TGT,
((MLOC.SFTY_STK_QTY * MAU.FACT_NUMRTR_MEAS) / MAU.FACT_DENOM_MEAS) AS "SFTY_STK_QTY_IN_EACHES",
REPLENISHMENT_LEAD_DAY_CNT,
REPLENISHMENT_PRCS_CD
FROM SCMAIN_V.MATL_LOC MLOC
LEFT OUTER JOIN
(
SELECT
MATL_ID, BASE_UOM_CD , ALT_UOM_CD,FACT_NUMRTR_MEAS,FACT_DENOM_MEAS,FINANCIAL_SYSTEM_ID
FROM
SCMAIN_V.MATL_ALT_UOM
WHERE ALT_UOM_CD = 'EA'
AND TRIM(SRC_SYS_CD) LIKE 'M%'
QUALIFY ROW_NUMBER() OVER(PARTITION BY
MATL_ID, BASE_UOM_CD
ORDER BY DAI_UPDT_DTTM DESC, FACT_DENOM_MEAS ASC)=1
) MAU
ON MLOC.MATL_ID = MAU.MATL_ID
AND MLOC.BASE_UOM_CD = MAU.BASE_UOM_CD
WHERE MLOC.SYS_VLD_TO_DT = TIMESTAMP '9999-12-31 00:00:00'
);
答案 0 :(得分:2)
我认为您需要将 QUALIFY ROW_NUMBER()OVER(...)'操作重写为'SELECT ROW_NUMBER OVER(...)WHERE ROWNUM ='因为hive还不支持使用QUALIFY
,所以在内部查询中进行操作休息所有查询从蜂巢的角度来看都很好,包括CASE。 另一个小问题是在“SFTY_STK_QTY_IN_EACHES”使用双引号。
以下是您可以尝试使用的更改后的查询:
SKAction
答案 1 :(得分:0)