hive从子查询创建表

oyxsuwqo  于 2021-06-04  发布在  Hadoop
关注(0)|答案(2)|浏览(331)

这是我的密码:

create table sw_tmp6_gar_crm as
SELECT * FROM(
  select as_fid_x_gara.dat_fine_perio        as dat_fine_perio,
         as_fid_x_gara.cod_soc               as cod_soc, 
         as_fid_x_gara.cod_kto_gar           as cod_kto_gar, 
         as_fid_x_gara.cod_fido              as cod_fido,
         fid.dat_delib             as dat_delib, 
         fid.dat_scad              as dat_scad  

  from   it_soc_x_fv,
         as_fid_x_gara   ,
         rt_fidi         
  where  it_soc_x_fv.flg_tp_soc     in ('C','N')
    and  as_fid_x_gara.dat_fine_perio   = 2008-03-06
    and  as_fid_x_gara.cod_soc          = it_soc_x_fv.cod_soc
    and  rt_fidi.dat_fine_perio   = as_fid_x_gara.dat_fine_perio
    and  rt_fidi.cod_soc          = as_fid_x_gara.cod_soc       
    and  rt_fidi.cod_fido_tecnico = as_fid_x_gara.cod_fido 
     )         
;

我收到以下错误:
编译语句时出错:失败:parseexception行10:9无法将“it\u soc\u x\u fv”“附近的输入识别为源中的\u fid\u x\u gara”
你能帮我吗?

zqdjd7g9

zqdjd7g91#

你得给我个建议 alias 子查询的名称。下面的那个应该有用。

create table sw_tmp6_gar_crm as
SELECT * FROM(
  select as_fid_x_gara.dat_fine_perio        as dat_fine_perio,
         as_fid_x_gara.cod_soc               as cod_soc, 
         as_fid_x_gara.cod_kto_gar           as cod_kto_gar, 
         as_fid_x_gara.cod_fido              as cod_fido,
         fid.dat_delib             as dat_delib, 
         fid.dat_scad              as dat_scad  

  from   it_soc_x_fv,
         as_fid_x_gara   ,
         rt_fidi         
  where  it_soc_x_fv.flg_tp_soc     in ('C','N')
    and  as_fid_x_gara.dat_fine_perio   = 2008-03-06
    and  as_fid_x_gara.cod_soc          = it_soc_x_fv.cod_soc
    and  rt_fidi.dat_fine_perio   = as_fid_x_gara.dat_fine_perio
    and  rt_fidi.cod_soc          = as_fid_x_gara.cod_soc       
    and  rt_fidi.cod_fido_tecnico = as_fid_x_gara.cod_fido 
     ) tmp         
;

但是正如评论中提到的,您不需要子查询。

11dmarpk

11dmarpk2#

您没有正确地为表添加别名。在from语句中,您没有提到表的任何别名,在select列中,您说的是fid.dat\u delib、fid.dat\u scad。
但查询中没有fid表或别名。
如前所述,不需要子查询,可以直接编写查询而不需要子查询。

相关问题