这段sql长这样
insert into t_track_pro_code (track_pro_code,track_pro_code_name) select (with tb1 as (
select distinct m.track_pro_code from ba_bgt_info_hz m where m.ori_bgt_id in (
select t.bgt_id from ba_bgt_info_hz t where t.track_pro_code in (select distinct track_pro_code from ba_bgt_info_hz
where bgt_doc_title like '%车辆购置税收入补助地方资金%' and is_deleted=2 and track_pro_code is not null and importtype not in (8,9))
and t.billstatus>=0 and t.importtype not in (8,9)
) and m.importtype not in (8,9) union
select distinct track_pro_code from ba_bgt_info_hz
where bgt_doc_title like '%车辆购置税收入补助地方资金%' and is_deleted=2 and track_pro_code is not null and importtype not in (8,9)
) select distinct track_pro_code track_pro_code_name from tb1) track_pro_code,'车辆购置税收入补助地方资金'
track_pro_code_name from dual
大概就是这样写的tab1只有两列哈。
insert into tab1 select (一个临时表),'名称' from dual;
这样报错,因为我临时表查出来是两行值 不重复的,然后name列我想写死。我想达到的效果是
1234 资金a
9876 资金a
//其中1234和9876是我从with表查出来的
有没有宝宝帮我改一下代码 达到我想要的效果!有偿!