A Hidden Covering Problem in Union Query

A relatively hidden coverage problem in the joint query. If there are fields with the same name in the select, only the former ones will be taken, so you need to take the latter ones and give them an alias.

    As follows: there is NEW_PRICE (empty) in t, so take NEW_PRICE (valued) in t4, then the latter one without aliasing will directly take the previous empty one

       select t.*,

       t1.*,

       FC_GET_SPZL(t1.P201, 'CN') spzl_cn,

       FC_GET_SPZL(t1.P201, 'CN') spzl,

       FC_GET_SPZL(t1.P201, 'EN') spzl_en,

       FC_GET_NUMUINT_EN(t.NUM_UNIT) NUM_UNIT_EN,

       FC_GET_NUMUINT_CN(t.NUM_UNIT) NUM_UNIT_CN,

       FC_GET_NUMUINT_EN(t.PRICE_UNIT2) PRICE_UNIT2_EN,

       FC_GET_NUMUINT_CN(t.PRICE_UNIT2) PRICE_UNIT2_CN,

       FC_GET_WARE_JGSY(t.obj_ware_key) JGSY_CN,

       FC_GET_WARE_JGSY(t.obj_ware_key) JGSY,

       FC_GET_WARE_JGSY_EN(t.obj_ware_key) JGSY_EN,

       t3.WAREKIND_NAME,

       t2.WARE_NAME,

       t4.NEW_NUM,

       t4.NEW_PRICE  NEW_PRICE1,

       t4.OBJ_WARE_KEY

       from tb_con_obj_ware t,

          (select * from tb_data_all where linktype = 'B1') t1,

          tb_bas_bed t2,

          tb_bas_bed_srt t3,

          (select t.OBJ_WARE_KEY, NEW_NUM, NEW_PRICE

          from TB_CON_ORD_PRICE_DTL t,

          (select max(ord_key) ord_key, max(ordprice_no) ordprice_no 

          from tb_con_ord_price

          where is_newprice = 'Y'

          and ORDPRICE_MAN = 'B'

          and ord_key in (select ord_key

             from tb_con_ord

             where 1=1   AND conobj_key = '6107'

   and customer_key='545'

     and ORDER_STATUS = 'A')) t2

             where t.ord_key = t2.ord_key

             and t.ORDPRICE_NO = t2.ORDPRICE_NO) t4

             where t.obj_ware_key = t1.linkkey

             and t.warekind_key = t3.warekind_key

             and t.ware_key = t2.ware_key

             and t.conobj_key = '6107'

    and t.obj_ware_key = t4.OBJ_WARE_KEY(+)

             order by t.obj_ware_key

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326486951&siteId=291194637