gpt4 book ai didi

sql - Hive JOIN 中遇到的左右别名;没有任何不平等条款

转载 作者:行者123 更新时间:2023-12-04 01:23:40 32 4
gpt4 key购买 nike

我正在使用以下查询:

Select
S.MDSE_ITEM_I,
S.CO_LOC_I,
MAX(S.SLS_D) as MAX_SLS_D,
MIN(S.SLS_D) as MIN_SLS_D,
sum(S.SLS_UNIT_Q) as SLS_UNIT_Q,
MIN(PRSMN_VAL_STRT_D) as PRSMN_VAL_STRT_D,
MIN(PRSMN_VAL_END_D) as PRSMN_VAL_END_D,
MIN(RC.FRST_RCPT_D) as FRST_RCPT_D,
MIN(RC.CURR_ACTV_FRST_OH_D) as CURR_ACTV_FRST_OH_D,
MIN(H.GREG_D) as OH_GREG_D
from
eefe_lstr4.SLS_TBL as S
left outer join
eefe_lstr4.PRS_TBL P
on S.MDSE_ITEM_I = P.MDSE_ITEM_I
and S.CO_LOC_I = P.CO_LOC_I
and S.SLS_D between PRSMN_VAL_STRT_D and PRSMN_VAL_END_D
left outer join
eefe_lstr4.OROW_RCPT RC
on RC.MDSE_ITEM_I =S.MDSE_ITEM_I
and RC.CO_LOC_I = S.CO_LOC_I
left outer join
eefe_lstr4.OH H
on H.MDSE_ITEM_I =S.MDSE_ITEM_I
and H.CO_LOC_I = S.CO_LOC_I
group by
S.MDSE_ITEM_I,
S.CO_LOC_I;

我收到错误说:

FAILED: SemanticException Line 0:-1 Both left and right aliases encountered in JOIN 'PRSMN_VAL_END_D'



搜索显示当查询中有不等式子句时会出现此错误。但是,我没有使用任何不等式子句( <=>= 在我的查询中(只是 =between ),即使我收到此错误。

最佳答案

尝试将不等式条件从 on 子句移动到 where 条件。

Select S.MDSE_ITEM_I,S.CO_LOC_I,
MAX(S.SLS_D) as MAX_SLS_D,
MIN(S.SLS_D) as MIN_SLS_D,
sum(S.SLS_UNIT_Q) as SLS_UNIT_Q,
MIN(PRSMN_VAL_STRT_D) as PRSMN_VAL_STRT_D,
MIN(PRSMN_VAL_END_D) as PRSMN_VAL_END_D,
MIN(RC.FRST_RCPT_D) as FRST_RCPT_D,
MIN(RC.CURR_ACTV_FRST_OH_D) as CURR_ACTV_FRST_OH_D,
MIN(H.GREG_D) as OH_GREG_D
from eefe_lstr4.SLS_TBL as S
left outer join eefe_lstr4.PRS_TBL P on S.MDSE_ITEM_I = P.MDSE_ITEM_I and S.CO_LOC_I = P.CO_LOC_I
left outer join eefe_lstr4.OROW_RCPT RC on RC.MDSE_ITEM_I =S.MDSE_ITEM_I and RC.CO_LOC_I = S.CO_LOC_I
left outer join eefe_lstr4.OH H on H.MDSE_ITEM_I =S.MDSE_ITEM_I and H.CO_LOC_I = S.CO_LOC_I
where(S.SLS_D between PRSMN_VAL_STRT_D and PRSMN_VAL_END_D)
group by S.MDSE_ITEM_I, S.CO_LOC_I;

关于sql - Hive JOIN 中遇到的左右别名;没有任何不平等条款,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39852325/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com