bigqueryのテーブルに対して、加工処理を実施したいです。
T_RS_TRAN_TESTのデータに、M_SUBINV_TESTとM_ORG_TESTのデータから必要なカラム値を入れ込みます。
SQLエラーが出力されている状況となります。
●加工用のSQL update `embulk_test.T_RS_TRAN_TEST` rs set from_org_name = (select org_name from `embulk_test.M_ORG_TEST` where org_code = rs.from_org_code and row_num = 1 ),to_org_name = (select org_name from `embulk_test.M_ORG_TEST` where org_code = rs.to_org_code and row_num = 1 ),from_subinv_name = (select subinv_name from `embulk_test.M_SUBINV_TEST` where org_code = rs.from_org_code and subinv_code = rs.subinv_code and row_num = 1 ),to_subinv_name = (select subinv_name from `embulk_test.M_SUBINV_TEST` where org_code = rs.to_org_code and subinv_code = rs.subinv_code and row_num = 1 ) where ( rs.from_org_name is null or rs.to_org_name is null or from_subinv_name is null or to_subinv_name is null); ●エラー Unrecognized name:row_num at[1:145] ●テーブル定義 CREATE TABLE T_RS_TRAN_TEST ( ORDER_ID VARCHAR2(16), FACTORY_NAME VARCHAR2(10), FROM_FACTORY_NAME VARCHAR2(10), TO_FACTORY_NAME VARCHAR2(10), FROM_ORG_NAME VARCHAR2(10), FROM_SUBINV_NAME VARCHAR2(10), TO_ORG_NAME VARCHAR2(10), TO_SUBINV_NAME VARCHAR2(10), TO_ORG_CODE VARCHAR2(10), FROM_ORG_CODE VARCHAR2(10) PRIMARY KEY(ORDER_ID) ); CREATE TABLE M_SUBINV_TEST ( ORG_CODE VARCHAR2(10), SUBINV_CODE VARCHAR2(10), SUBINV_NAME VARCHAR2(10), PRIMARY KEY(ORG_CODE) ); CREATE TABLE M_ORG_TEST ( ORG_CODE VARCHAR2(10), ORG_NAME VARCHAR2(10), PRIMARY KEY(ORG_CODE) );
※20190318 実行状況
●SQL update `embulk_test.T_RS_TRAN_TEST` rs set from_org_name = (select org_name from `embulk_test.M_ORG_TEST` where org_code = rs.from_org_code and ROW_NUMBER() OVER `1`), to_org_name = (select org_name from `embulk_test.M_ORG_TEST` where org_code = rs.to_org_code and ROW_NUMBER() OVER `1`), from_subinv_name = (select subinv_name from `embulk_test.M_SUBINV_TEST` where org_code = rs.from_org_code and subinv_code = rs.subinv_code and ROW_NUMBER() OVER `1`), to_subinv_name = (select subinv_name from `embulk_test.M_SUBINV_TEST` where org_code = rs.to_org_code and subinv_code = rs.subinv_code and ROW_NUMBER() OVER `1`) where ( rs.from_org_name is null or rs.to_org_name is null or from_subinv_name is null or to_subinv_name is null); ●エラー Analytic function not allowed in WHERE clause at [1:145]
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/03/13 08:46
2019/03/13 08:49