代码之家  ›  专栏  ›  技术社区  ›  Pat Doyle

HiveQL-连接在Select语句上创建的列

  •  1
  • Pat Doyle  · 技术社区  · 6 年前

    我正在尝试将配置单元中的两个表连接到多列上。我想连接的列之一是,我正在处理一些数据以匹配另一个表中的结构,然后我计划连接它。

    我的挑战是,我正在创建的专栏不允许我加入。我尝试了几种不同的方法,但到目前为止我都没有成功。感谢您的帮助!

    SELECT 
    prvdr_num, 
    CONCAT(SUBSTR(CLM_ADMSN_DT, 5, 2),"/",SUBSTR(CLM_ADMSN_DT, 7, 
    2),"/",SUBSTR(CLM_ADMSN_DT, 1, 4)) as Calendar_Admit_date,
    AdmitDate,
    CMSId
    FROM table1
    INNER JOIN  table2
    ON table1.CMSId = table2_lds.prvdr_num
    AND table1.AdmitDate = 
    table2.CONCAT(SUBSTR(CLM_ADMSN_DT, 5, 2),"/",SUBSTR(CLM_ADMSN_DT, 7, 
    2),"/",SUBSTR(CLM_ADMSN_DT, 1, 4))
    

    我也尝试过这个,但它不会起作用。

    SELECT 
    prvdr_num, 
    CONCAT(SUBSTR(CLM_ADMSN_DT, 5, 2),"/",SUBSTR(CLM_ADMSN_DT, 7, 
    2),"/",SUBSTR(CLM_ADMSN_DT, 1, 4)) as Calendar_Admit_date,
    AdmitDate,
    CMSId
    FROM table1
    INNER JOIN  table2
    ON table1.CMSId = table2_lds.prvdr_num
    AND table1.AdmitDate = 
    table2.Calendar_Admit_date
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Daniel Marcus    6 年前

    您是否尝试将新专栏转换为加入的日期?

     SELECT 
        prvdr_num, 
        CONCAT(SUBSTR(CLM_ADMSN_DT, 5, 2),"/",SUBSTR(CLM_ADMSN_DT, 7, 
        2),"/",SUBSTR(CLM_ADMSN_DT, 1, 4)) as Calendar_Admit_date,
        AdmitDate,
        CMSId
        FROM table1
        INNER JOIN  table2
        ON table1.CMSId = table2_lds.prvdr_num
        AND table1.AdmitDate = 
        cast(CONCAT(SUBSTR(table2.CLM_ADMSN_DT, 5, 2),"/",SUBSTR(table2.CLM_ADMSN_DT, 7, 
        2),"/",SUBSTR(table2.CLM_ADMSN_DT, 1, 4)) as date)