【SRM】649 t2

题意

一个数列\(A\),数的范围均在\([0, 2^N-1]\)内,求一个\(B\),使得新生成的数列\(C\)中逆序对最多(\(C_i = A_i xor B\)),输出最多的逆序对。(\(|A|<=10^5\)

分析

这种题当然要逐位考虑..考虑到二进制和xor,我们需要想到trie...

题解

将数列插入到一棵trie,我们在每一个层记录一个信息,表示\(B\)在这一层取\(0\)或取\(1\)新增的逆序对数,然后统计答案即可。
而由于是xor操作,所以很好统计,我们可以每插入一个数就统计一次。

// BEGIN CUT HERE

// END CUT HERE
#line 5 "XorSequence.cpp"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
const int N=150005;
struct node {
    node *c[2];
    int s;
    void init() {
        c[0]=c[1]=0;
        s=0;
    }
}Po[N*31], *iT=Po, *root=0;
ll c[31][2];
node *newnode() {
    iT->init();
    return iT++;
}
void add(int w, int dep=29, node *&x=root) {
    if(!x) {
        x=newnode();
    }
    ++x->s;
    if(dep<0) {
        return;
    }
    int f=(w>>dep)&1;
    if(f) {
        add(w, dep-1, x->c[1]);
        if(x->c[0]) {
            c[dep][0]+=x->c[0]->s;
        }
    }
    else {
        add(w, dep-1, x->c[0]);
        if(x->c[1]) {
            c[dep][1]+=x->c[1]->s;
        }
    }
}
class XorSequence {
public:
    long long getmax(int N, int sz, int A0, int A1, int P, int Q, int R) {
        iT=Po;
        root=0;
        memset(c, 0, sizeof c);
        add(A0);
        for(int i=1; i<sz; ++i) {
            add(A1);
            int t=A1;
            A1=(1ll*A0*P+1ll*A1*Q+R)%N;
            A0=t;
        }
        ll ans=0;
        for(int i=0; i<30; ++i) {
            ans+=max(c[i][0], c[i][1]);
        }
        return ans;
    }

// BEGIN CUT HERE
    public:
    void run_test(int Case) { if ((Case == -1) || (Case == 0)) test_case_0(); if ((Case == -1) || (Case == 1)) test_case_1(); if ((Case == -1) || (Case == 2)) test_case_2(); if ((Case == -1) || (Case == 3)) test_case_3(); if ((Case == -1) || (Case == 4)) test_case_4(); if ((Case == -1) || (Case == 5)) test_case_5(); }
    private:
    template <typename T> string print_array(const vector<T> &V) { ostringstream os; os << "{ "; for (typename vector<T>::const_iterator iter = V.begin(); iter != V.end(); ++iter) os << '\"' << *iter << "\","; os << " }"; return os.str(); }
    void verify_case(int Case, const long long &Expected, const long long &Received) { cerr << "Test Case #" << Case << "..."; if (Expected == Received) cerr << "PASSED" << endl; else { cerr << "FAILED" << endl; cerr << "\tExpected: \"" << Expected << '\"' << endl; cerr << "\tReceived: \"" << Received << '\"' << endl; } }
    void test_case_0() { int Arg0 = 4; int Arg1 = 6; int Arg2 = 3; int Arg3 = 2; int Arg4 = 0; int Arg5 = 1; int Arg6 = 3; long long Arg7 = 8LL; verify_case(0, Arg7, getmax(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)); }
    void test_case_1() { int Arg0 = 8; int Arg1 = 8; int Arg2 = 2; int Arg3 = 5; int Arg4 = 3; int Arg5 = 1; int Arg6 = 4; long long Arg7 = 13LL; verify_case(1, Arg7, getmax(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)); }
    void test_case_2() { int Arg0 = 8; int Arg1 = 7; int Arg2 = 3; int Arg3 = 0; int Arg4 = 1; int Arg5 = 2; int Arg6 = 4; long long Arg7 = 12LL; verify_case(2, Arg7, getmax(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)); }
    void test_case_3() { int Arg0 = 32; int Arg1 = 15; int Arg2 = 7; int Arg3 = 9; int Arg4 = 11; int Arg5 = 2; int Arg6 = 1; long long Arg7 = 60LL; verify_case(3, Arg7, getmax(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)); }
    void test_case_4() { int Arg0 = 131072; int Arg1 = 131072; int Arg2 = 7; int Arg3 = 7; int Arg4 = 1; int Arg5 = 0; int Arg6 = 0; long long Arg7 = 0LL; verify_case(4, Arg7, getmax(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)); }
    void test_case_5() { int Arg0 = 131072; int Arg1 = 131070; int Arg2 = 411; int Arg3 = 415; int Arg4 = 398; int Arg5 = 463; int Arg6 = 9191; long long Arg7 = 4302679760LL; verify_case(5, Arg7, getmax(Arg0, Arg1, Arg2, Arg3, Arg4, Arg5, Arg6)); }

// END CUT HERE

};

// BEGIN CUT HERE
int main() {
    XorSequence ___test;
    ___test.run_test(-1);
    return 0;
}
// END CUT HERE

转载于:https://www.cnblogs.com/iwtwiioi/p/4986437.html

sql语法错误,信息: mismatched input '(' expecting ')'(line 4, pos 22) == SQL == with huilv as ( -- 所有年月汇率 select CONCAT(CAST(t2.year AS STRING) as year, LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, t2.exchange_rate as qty ----------------------^^^ FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.exchange_rate is not null group by CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')), t2.exchange_rate order by CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) ), huilv_data as ( -- 所有内存条代码汇率 select t0.item_no, '汇率' as data_type, t2.year as cal_year, t2.cal_date, t2.qty FROM dm_sever_label_nct t0 left join huilv t2 where t0.item_no is not null and t2.qty is not null ), gbs as ( -- 所有内存条代码GB单位 select main_ida.text_field_ooil5pe9 as item_no, main_ida.text_field_2lnermdr as qty from ods_ida_t_app0896034115789864961_m1192517514695749632 main_ida where main_ida.id = (select max(ida.id) from ods_ida_t_app0896034115789864961_m1192517514695749632 ida where ida.text_field_ooil5pe9 = main_ida.text_field_ooil5pe9) ), ls_jl_gb as ( -- 历史进料GB select t0.item_no, '历史进料GB' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, t1.acpt_qty*gb.qty as qty FROM dm_sever_label_nct t0 left join gbs gb on t0.item_no = gb.item_no left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where gb.item_no is not null and t1.item_no is not null and t2.id is not null ), ls_jl_sl as ( -- 历史进料数量 select t0.item_no, '历史进料数量(条)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, t1.acpt_qty as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' ), ls_jl_dj_cny as ( -- 历史进料单价 select t0.item_no, '历史进料单价(CNY/条)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, t1.old_std_price as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' ), ls_jl_dj_usd as ( -- 历史进料单价 select t0.item_no, '历史进料单价(USD/条)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, t1.old_orig_price as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' ), ls_jl_je as ( -- 历史进料金额 select t0.item_no, '历史进料金额(CNY)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, t1.acpt_std_amount as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' ), ls_jl_dj_cnygb as ( -- 历史进料单价 select t0.item_no, '历史进料单价(CNY/GB)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, t0.qty/t1.qty as qty FROM ls_jl_dj_cny t0 left join gbs t1 ON t1.item_no = t0.item_no and t1.cal_date = t0.cal_date where t1.item_no is not null ), ls_jl_dj_usdgb as ( -- 历史进料单价 select t0.item_no, '历史进料单价(USD/GB)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, t0.qty/t1.qty as qty FROM ls_jl_dj_usd t0 left join gbs t1 ON t1.item_no = t0.item_no and t1.cal_date = t0.cal_date where t1.item_no is not null ), ls_ck_dj_cny as ( select t0.item_no, '历史出库单价(CNY/条)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, t1.item_cost as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' ), ls_ck_dj_usd as ( select t0.item_no, '历史出库单价(USD/条)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, t1.item_cost/hl.qty as qty FROM dm_sever_label_nct t0 left join huilv_data hl on t0.item_no = hl.item_no left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' and SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) = hl.cal_date where t0.item_no is not null and t1.item_cost is not null ), ls_ck_je as ( select t0.item_no, '历史出库金额(CNY)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, sum(t1.outstock_money) as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, t1.p_date ), ls_ck_dj_cnygb as ( select t0.item_no, '历史出库单价GB(CNY/GB)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, t0.qty/t1.qty as qty FROM ls_ck_dj_cny t0 left join gbs t1 on t0.item_no = t1.item_no and t0.cal_date = t1.cal_date where t1.item_no is not null ), ls_ck_dj_usdgb as ( select t0.item_no, '历史出库单价GB(USD/GB)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, t0.qty/t1.qty as qty FROM ls_ck_dj_usd t0 left join gbs t1 on t0.item_no = t1.item_no and t0.cal_date = t1.cal_date where t1.item_no is not null ), ls_ck_sl as ( select t0.item_no, '历史出库数量(条)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, sum(t1.outstock_qty) as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, t1.p_date ), ls_ck_gb as ( select t0.item_no, '历史出库GB' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, sum(t1.outstock_qty*gb.qty) as qty FROM dm_sever_label_nct t0 left join gbs gb on t0.item_no = gb.item_no left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, t1.p_date ), main_data as ( select * from huilv_data --汇率 UNION select * from ls_jl_sl --历史进料条 UNION select * from ls_jl_gb --历史进料GB UNION select * from ls_jl_je --历史进料金额 UNION select * from ls_jl_dj_cnygb --历史进料单价元/GB UNION select * from ls_jl_dj_cny --历史进料单价元/条 UNION select * from ls_jl_dj_usdgb --历史进料单价USD/GB UNION select * from ls_jl_dj_usd --历史进料单价USD/条 UNION select * from ls_ck_sl --历史出库条 UNION select * from ls_ck_gb --历史出库gb UNION select * from ls_ck_je --历史出库金额 UNION select * from ls_ck_dj_cny --历史出库单价元/条 UNION select * from ls_ck_dj_cnygb --历史出库单价元/GB UNION select * from ls_ck_dj_usdgb --历史出库单价usd/GB UNION select * from ls_ck_dj_usd --历史出库单价USD/条 ) INSERT OVERWRITE TABLE dm_server_price_stock_202512 select nct.item_no, '' as item_name, nct.class1, nct.class2, nct.item_bm as bm, '' as jixing, nct.kehu, nct.is_china, nct.is_zte, nct.item_pp, main.data_type, main.cal_year, main.cal_date, main.qty, 0 as num_other1, 0 as num_other2, 0 as num_other3, 0 as num_other4, '' as num_other1, '' as num_other2, '' as num_other3, '' as num_other4, '' as edw_create_date, '' as edw_last_update, '' as edw_data_source, '' as valid_flag from dm_sever_label_nct nct left join qt0 main on main.item_no = nct.item_no
12-16
分析如下sparksql代码存在的问题: with huilv as ( -- 所有年月汇率 select t2.year, CONCAT(CAST(t2.year AS STRING), LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, min(t2.exchange_rate) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.exchange_rate is not null and t2.year is not null and t2.month is not null group by t2.year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) order by CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) ), huilv_data as ( -- 所有内存条代码汇率 select t0.item_no, '汇率' as data_type, t2.year as cal_year, t2.cal_date, t2.qty FROM dm_sever_label_nct t0 left join huilv t2 where t0.item_no is not null and t2.qty is not null ), ls_jl_gb as ( -- 历史进料GB select t0.item_no, '历史进料GB' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, SUM(CAST(t1.acpt_qty as float)*CAST(t0.item_rlgb1 as float)) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.id is not null group by t0.item_no, t2.year, t2.month ), ls_jl_sl as ( -- 历史进料数量 select t0.item_no, '历史进料数量(条)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, sum(t1.acpt_qty) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.id is not null group by t0.item_no, t2.year, t2.month ), ls_jl_dj_cny as ( -- 历史进料单价 select t0.item_no, '历史进料单价(CNY/条)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, min(t1.old_std_price) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.id is not null group by t0.item_no, t2.year, t2.month ), ls_jl_dj_usd as ( -- 历史进料单价 select t0.item_no, '历史进料单价(USD/条)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, min(t1.old_orig_price) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.id is not null group by t0.item_no, t2.year, t2.month ), ls_jl_je as ( -- 历史进料金额 select t0.item_no, '历史进料金额(CNY)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, sum(t1.acpt_std_amount) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.id is not null group by t0.item_no, t2.year, t2.month ), ls_jl_dj_cnygb as ( -- 历史进料单价 select t0.item_no, '历史进料单价(CNY/GB)' as data_type, t0.cal_year, t0.cal_date, min(cast(t0.qty as float)/CAST(t1.item_rlgb1 as float)) as qty FROM ls_jl_dj_cny t0 left join dm_sever_label_nct t1 ON t1.item_no = t0.item_no where t1.item_no is not null group by t0.item_no, t0.cal_year, t0.cal_date ), ls_jl_dj_usdgb as ( -- 历史进料单价 select t0.item_no, '历史进料单价(USD/GB)' as data_type, t0.cal_year, t0.cal_date, min(t0.qty/CAST(t1.item_rlgb1 as float)) as qty FROM ls_jl_dj_usd t0 left join dm_sever_label_nct t1 ON t1.item_no = t0.item_no where t1.item_no is not null group by t0.item_no, t0.cal_year, t0.cal_date ), ls_ck_dj_cny as ( select t0.item_no, '历史出库单价(CNY/条)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, min(t1.item_cost) as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) ), ls_ck_dj_usd as ( select t0.item_no, '历史出库单价(USD/条)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, min(CAST(t1.item_cost as float)/CAST(hl.qty as float)) as qty FROM dm_sever_label_nct t0 left join huilv_data hl on t0.item_no = hl.item_no left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' and SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) = hl.cal_date where t0.item_no is not null and t1.item_cost is not null group by t0.item_no, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) ), ls_ck_je as ( select t0.item_no, '历史出库金额(CNY)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, sum(t1.outstock_money) as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) ), ls_ck_dj_cnygb as ( select t0.item_no, '历史出库单价GB(CNY/GB)' as data_type, t0.cal_year, t0.cal_date, min(CAST(t0.qty as float)/CAST(t1.item_rlgb1 as float)) as qty FROM ls_ck_dj_cny t0 left join dm_sever_label_nct t1 on t0.item_no = t1.item_no where t1.item_no is not null group by t0.item_no, t0.cal_year, t0.cal_date ), ls_ck_dj_usdgb as ( select t0.item_no, '历史出库单价GB(USD/GB)' as data_type, t0.cal_year, t0.cal_date, min(CAST(t0.qty as float)/CAST(t1.item_rlgb1 as float)) as qty FROM ls_ck_dj_usd t0 left join dm_sever_label_nct t1 on t0.item_no = t1.item_no where t1.item_no is not null group by t0.item_no, t0.cal_year, t0.cal_date ), ls_ck_sl as ( select t0.item_no, '历史出库数量(条)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, sum(t1.outstock_qty) as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) ), ls_ck_gb as ( select t0.item_no, '历史出库GB' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, sum(CAST(t1.outstock_qty as float)*CAST(t0.item_rlgb1 as float)) as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) ), ls_kc_sl as ( select t0.item_no, '历史库存数量(条)' as data_type, SUBSTR(t1.cal_date, 1, 4) as cal_year, SUBSTR(t1.cal_date, 1, 6) as cal_date, min(t1.qty) as qty FROM dm_sever_label_nct t0 left join dm_server_history_stock t1 on t0.item_no = t1.item_no where t1.item_no is not null and t1.cal_date is not null group by t0.item_no, SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 6) ), ls_kc_gb as ( select t0.item_no, '历史库存GB' as data_type, SUBSTR(t1.cal_date, 1, 4) as cal_year, SUBSTR(t1.cal_date, 1, 6) as cal_date, sum(t1.qty*t0.item_rlgb1) as qty FROM dm_sever_label_nct t0 left join dm_server_history_stock t1 on t0.item_no = t1.item_no where t1.item_no is not null and t1.cal_date is not null group by t0.item_no, SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 6) ), ls_kc_cny as ( select t0.item_no, '历史库存单价(CNY)' as data_type, SUBSTR(t1.cal_date, 1, 4) as cal_year, SUBSTR(t1.cal_date, 1, 6) as cal_date, min(t1.stock_amount/t1.qty) as qty FROM dm_sever_label_nct t0 left join dm_server_history_stock t1 on t0.item_no = t1.item_no where t1.item_no is not null and t1.cal_date is not null group by t0.item_no, SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 6) ), ls_kc_usd as ( select t0.item_no, '历史库存单价(USD)' as data_type, t1.cal_year, t1.cal_date, min(t1.qty/t2.qty) as qty FROM dm_sever_label_nct t0 left join ls_kc_cny t1 on t0.item_no = t1.item_no left join huilv_data t2 on t0.item_no = t1.item_no and t1.cal_date = t2.cal_date where t1.item_no is not null and t2.item_no is not null and t1.cal_date is not null group by t0.item_no, t1.cal_year, t1.cal_date ), ls_kc_cnygb as ( select t0.item_no, '历史库存单价(CNY/GB)' as data_type, SUBSTR(t1.cal_date, 1, 4) as cal_year, SUBSTR(t1.cal_date, 1, 6) as cal_date, min(t1.stock_amount/t0.item_rlgb1) as qty FROM dm_sever_label_nct t0 left join dm_server_history_stock t1 on t0.item_no = t1.item_no where t1.item_no is not null and t1.cal_date is not null group by t0.item_no, SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 6) ), ls_kc_usdgb as ( select t0.item_no, '历史库存单价(USD/GB)' as data_type, t1.cal_year, t1.cal_date, min(t1.qty/t0.item_rlgb1) as qty FROM dm_sever_label_nct t0 left join ls_kc_usd t1 on t0.item_no = t1.item_no where t1.item_no is not null and t1.cal_date is not null group by t0.item_no, t1.cal_year, t1.cal_date ), main_data as ( select * from ls_kc_sl --历史库存数量 UNION ALL select * from ls_kc_gb --历史库存GB UNION ALL select * from ls_kc_cny --历史库存CNY UNION ALL select * from ls_kc_usd --历史库存USD UNION ALL select * from ls_kc_cnygb --历史库存CNY/GB UNION ALL select * from ls_kc_usdgb --历史库存USD/GB UNION ALL select * from huilv_data --汇率 UNION ALL select * from ls_jl_sl --历史进料条 UNION ALL select * from ls_jl_gb --历史进料GB UNION ALL select * from ls_jl_je --历史进料金额 UNION ALL select * from ls_jl_dj_cnygb --历史进料单价元/GB UNION ALL select * from ls_jl_dj_cny --历史进料单价元/条 UNION ALL select * from ls_jl_dj_usdgb --历史进料单价USD/GB UNION ALL select * from ls_jl_dj_usd --历史进料单价USD/条 UNION ALL select * from ls_ck_sl --历史出库条 UNION ALL select * from ls_ck_gb --历史出库gb UNION ALL select * from ls_ck_je --历史出库金额 UNION ALL select * from ls_ck_dj_cny --历史出库单价元/条 UNION ALL select * from ls_ck_dj_cnygb --历史出库单价元/GB UNION ALL select * from ls_ck_dj_usdgb --历史出库单价usd/GB UNION ALL select * from ls_ck_dj_usd --历史出库单价USD/条 ) INSERT OVERWRITE TABLE dm_server_price_stock_202512 select nct.item_no, '' as item_name, nct.class1, nct.class2, nct.item_bm as bm, '' as jixing, nct.kehu, nct.is_china, nct.is_zte, nct.item_pp, main.data_type, main.cal_year, main.cal_date, main.qty, 0 as num_other1, 0 as num_other2, 0 as num_other3, 0 as num_other4, '' as num_other1, '' as num_other2, '' as num_other3, '' as num_other4, '' as edw_create_date, '' as edw_last_update, '' as edw_data_source, '' as valid_flag from dm_sever_label_nct nct left join main_data main on main.item_no = nct.item_no
12-17
sql语法错误,信息: mismatched input 'by' expecting ')'(line 10, pos 10) == SQL == with huilv as ( -- 所有年月汇率 select t2.year, CONCAT(CAST(t2.year AS STRING), LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, min(t2.exchange_rate) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.exchange_rate is not null and t2.year is not null and t2.month is not null group by t2.year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')), order by CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) ----------^^^ ), huilv_data as ( -- 所有内存条代码汇率 select t0.item_no, '汇率' as data_type, t2.year as cal_year, t2.cal_date, t2.qty FROM dm_sever_label_nct t0 left join huilv t2 where t0.item_no is not null and t2.qty is not null ), ls_jl_gb as ( -- 历史进料GB select t0.item_no, '历史进料GB' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, SUM(CAST(t1.acpt_qty as float)*CAST(t0.item_rlgb1 as float)) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.id is not null group by t0.item_no, t2.year, t2.month ), ls_jl_sl as ( -- 历史进料数量 select t0.item_no, '历史进料数量(条)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, sum(t1.acpt_qty) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.id is not null group by t0.item_no, t2.year, t2.month ), ls_jl_dj_cny as ( -- 历史进料单价 select t0.item_no, '历史进料单价(CNY/条)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, first(t1.old_std_price) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.id is not null group by t0.item_no, t2.year, t2.month ), ls_jl_dj_usd as ( -- 历史进料单价 select t0.item_no, '历史进料单价(USD/条)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, first(t1.old_orig_price) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.id is not null group by t0.item_no, t2.year, t2.month ), ls_jl_je as ( -- 历史进料金额 select t0.item_no, '历史进料金额(CNY)' as data_type, t2.year as cal_year, CONCAT(CAST(t2.year AS STRING),LPAD (CAST(t2.month AS STRING), 2, '0')) as cal_date, sum(t1.acpt_std_amount) as qty FROM dm_sever_label_nct t0 left join ods_srm_pu_acceptance_item t1 ON t1.item_no = t0.item_no and t1.has_red = 0 left JOIN ods_srm_pu_acceptance t2 ON t1.acpt_id = t2.id AND t2.dr = 0 AND t2.latest = 1 and t2.source_type='InStorage' and t2.std_currency = 'CNY' and t2.orig_currency = 'USD' where t1.item_no is not null and t2.id is not null group by t0.item_no, t2.year, t2.month ), ls_jl_dj_cnygb as ( -- 历史进料单价 select t0.item_no, '历史进料单价(CNY/GB)' as data_type, t0.cal_year, t0.cal_date, first(cast(t0.qty as float)/CAST(t1.item_rlgb1 as float)) as qty FROM ls_jl_dj_cny t0 left join dm_sever_label_nct t1 ON t1.item_no = t0.item_no where t1.item_no is not null group by t0.item_no, t0.cal_year, t0.cal_date ), ls_jl_dj_usdgb as ( -- 历史进料单价 select t0.item_no, '历史进料单价(USD/GB)' as data_type, t0.cal_year, t0.cal_date, first(t0.qty/CAST(t1.item_rlgb1 as float)) as qty FROM ls_jl_dj_usd t0 left join dm_sever_label_nct t1 ON t1.item_no = t0.item_no where t1.item_no is not null group by t0.item_no, t0.cal_year, t0.cal_date ), ls_ck_dj_cny as ( select t0.item_no, '历史出库单价(CNY/条)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, first(t1.item_cost) as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) ), ls_ck_dj_usd as ( select t0.item_no, '历史出库单价(USD/条)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, first(CAST(t1.item_cost as float)/CAST(hl.qty as float)) as qty FROM dm_sever_label_nct t0 left join huilv_data hl on t0.item_no = hl.item_no left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' and SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) = hl.cal_date where t0.item_no is not null and t1.item_cost is not null group by t0.item_no, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) ), ls_ck_je as ( select t0.item_no, '历史出库金额(CNY)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, sum(t1.outstock_money) as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) ), ls_ck_dj_cnygb as ( select t0.item_no, '历史出库单价GB(CNY/GB)' as data_type, t0.cal_year, t0.cal_date, first(CAST(t0.qty as float)/CAST(t1.item_rlgb1 as float)) as qty FROM ls_ck_dj_cny t0 left join dm_sever_label_nct t1 on t0.item_no = t1.item_no where t1.item_no is not null group by t0.item_no, t0.cal_year, t0.cal_date ), ls_ck_dj_usdgb as ( select t0.item_no, '历史出库单价GB(USD/GB)' as data_type, t0.cal_year, t0.cal_date, first(CAST(t0.qty as float)/CAST(t1.item_rlgb1 as float)) as qty FROM ls_ck_dj_usd t0 left join dm_sever_label_nct t1 on t0.item_no = t1.item_no where t1.item_no is not null group by t0.item_no, t0.cal_year, t0.cal_date ), ls_ck_sl as ( select t0.item_no, '历史出库数量(条)' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, sum(t1.outstock_qty) as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) ), ls_ck_gb as ( select t0.item_no, '历史出库GB' as data_type, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4) as cal_year, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) as cal_date, sum(CAST(t1.outstock_qty as float)*CAST(t0.item_rlgb1 as float)) as qty FROM dm_sever_label_nct t0 left join edw_sup_mfg_material_transactions t1 on t1.inventory_item_code = t0.item_no and t1.transaction_source_type_name = '任务或计划' and t1.subinventory_code not like '%NX%' where t1.inventory_item_code is not null group by t0.item_no, SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.p_date, '-', ''), 1, 6) ), ls_kc_sl as ( select t0.item_no, '历史库存条' as data_type, SUBSTR(t1.cal_date, 1, 4) as cal_year, SUBSTR(t1.cal_date, 1, 6) as cal_date, t1.qty as qty FROM dm_sever_label_nct t0 left join dm_server_history_stock t1 on t0.item_no = t1.item_no where t1.item_no is not null and t1.cal_date is not null group by t0.item_no, SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 6), t1.qty ), ls_kc_gb as ( select t0.item_no, '历史库存GB' as data_type, SUBSTR(t1.cal_date, 1, 4) as cal_year, SUBSTR(t1.cal_date, 1, 6) as cal_date, sum(t1.qty*t0.item_rlgb1) as qty FROM dm_sever_label_nct t0 left join dm_server_history_stock t1 on t0.item_no = t1.item_no where t1.item_no is not null and t1.cal_date is not null group by t0.item_no, SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 6) ), ls_kc_cny as ( select t0.item_no, '历史库存单价(CNY)' as data_type, SUBSTR(t1.cal_date, 1, 4) as cal_year, SUBSTR(t1.cal_date, 1, 6) as cal_date, first(t1.stock_amount/t1.qty) as qty FROM dm_sever_label_nct t0 left join dm_server_history_stock t1 on t0.item_no = t1.item_no where t1.item_no is not null and t1.cal_date is not null group by t0.item_no, SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 6), t1.stock_amount, t1.qty ), ls_kc_usd as ( select t0.item_no, '历史库存单价(USD)' as data_type, t1.cal_year, t1.cal_date, first(t1.qty/t2.qty) as qty FROM dm_sever_label_nct t0 left join ls_kc_cny t1 on t0.item_no = t1.item_no left join huilv_data t2 on t0.item_no = t1.item_no and t1.cal_date = t2.cal_date where t1.item_no is not null and t2.item_no is not null and t1.cal_date is not null group by t0.item_no, t1.cal_year, t1.cal_date, t1.qty, t2.qty ), ls_kc_cnygb as ( select t0.item_no, '历史库存单价(CNY/GB)' as data_type, SUBSTR(t1.cal_date, 1, 4) as cal_year, SUBSTR(t1.cal_date, 1, 6) as cal_date, first(t1.stock_amount/t0.item_rlgb1) as qty FROM dm_sever_label_nct t0 left join dm_server_history_stock t1 on t0.item_no = t1.item_no where t1.item_no is not null and t1.cal_date is not null group by t0.item_no, SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 4), SUBSTR(REPLACE(t1.cal_date, '-', ''), 1, 6), t1.stock_amount, t0.item_rlgb1 ), ls_kc_usdgb as ( select t0.item_no, '历史库存单价(USD/GB)' as data_type, t1.cal_year, t1.cal_date, first(t1.qty/t0.item_rlgb1) as qty FROM dm_sever_label_nct t0 left join ls_kc_usd t1 on t0.item_no = t1.item_no where t1.item_no is not null and t1.cal_date is not null group by t0.item_no, t1.cal_year, t1.cal_date, t1.qty, t0.item_rlgb1 ), main_data as ( select * from ls_kc_sl --历史库存数量 UNION select * from ls_kc_gb --历史库存GB UNION select * from ls_kc_cny --历史库存CNY UNION select * from ls_kc_usd --历史库存USD UNION select * from ls_kc_cnygb --历史库存CNY/GB UNION select * from ls_kc_usdgb --历史库存USD/GB UNION select * from huilv_data --汇率 UNION select * from ls_jl_sl --历史进料条 UNION select * from ls_jl_gb --历史进料GB UNION select * from ls_jl_je --历史进料金额 UNION select * from ls_jl_dj_cnygb --历史进料单价元/GB UNION select * from ls_jl_dj_cny --历史进料单价元/条 UNION select * from ls_jl_dj_usdgb --历史进料单价USD/GB UNION select * from ls_jl_dj_usd --历史进料单价USD/条 UNION select * from ls_ck_sl --历史出库条 UNION select * from ls_ck_gb --历史出库gb UNION select * from ls_ck_je --历史出库金额 UNION select * from ls_ck_dj_cny --历史出库单价元/条 UNION select * from ls_ck_dj_cnygb --历史出库单价元/GB UNION select * from ls_ck_dj_usdgb --历史出库单价usd/GB UNION select * from ls_ck_dj_usd --历史出库单价USD/条 ) INSERT OVERWRITE TABLE dm_server_price_stock_202512 select nct.item_no, '' as item_name, nct.class1, nct.class2, nct.item_bm as bm, '' as jixing, nct.kehu, nct.is_china, nct.is_zte, nct.item_pp, main.data_type, main.cal_year, main.cal_date, main.qty, 0 as num_other1, 0 as num_other2, 0 as num_other3, 0 as num_other4, '' as num_other1, '' as num_other2, '' as num_other3, '' as num_other4, '' as edw_create_date, '' as edw_last_update, '' as edw_data_source, '' as valid_flag from dm_sever_label_nct nct left join main_data main on main.item_no = nct.item_no
12-17
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值