不可以的。
两种条件你可以采用union all.

解决方案 »

  1.   

    select a.IOB_Adv_Dep, b.material_id, b.data_count - isnull(k.Mat_count, 0) as Count,
    b.data_count, k.mat_count
    from iobill_hed_tb a
    join (select material_id, iob_id,data_count from iobill_det_tb) b on
    a.iob_id = b.iob_id
    left join
    (select c.factory_id, g.Meterial_ID as Meterial_ID,
    sum(g.Meterial_Count * f.data_count) as Mat_Count  from
    assist_factory_tb c
    join (
    select bill_id, factory_id from assist_bill_tb) d on d.factory_id = c.factory_id
    join (
    select iob_id, corr_id from iobill_hed_tb) e on e.corr_id = d.bill_id
    join (
    select iob_id, material_id, user_07, data_count from iobill_det_tb) f on f.iob_id = e.iob_id
    join (
    select product_id, serial_id, isstandard from assist_bill_product_tb) h on h.serial_id = f.user_07
    join (
    select mat_id, child_id as mat_id from bom_det_tb) g on 
    g.mat_id = f.material_id
    where h.isstandard=1
    group by c.factory_id, Meterial_ID) k on (k.factory_id = a.iob_adv_dep) and (k.Meterial_ID = b.material_id)
    where a.iob_kind_id = 'ASS_OUT'Union All select a.IOB_Adv_Dep, b.material_id, b.data_count - isnull(k.Mat_count, 0) as Count,
    b.data_count, k.mat_count
    from iobill_hed_tb a
    join (select material_id, iob_id,data_count from iobill_det_tb) b on
    a.iob_id = b.iob_id
    left join
    (select c.factory_id, g.Meterial_ID as Meterial_ID,
    sum(g.Meterial_Count * f.data_count) as Mat_Count  from
    assist_factory_tb c
    join (
    select bill_id, factory_id from assist_bill_tb) d on d.factory_id = c.factory_id
    join (
    select iob_id, corr_id from iobill_hed_tb) e on e.corr_id = d.bill_id
    join (
    select iob_id, material_id, user_07, data_count from iobill_det_tb) f on f.iob_id = e.iob_id
    join (
    select product_id, serial_id, isstandard from assist_bill_product_tb) h on h.serial_id = f.user_07
    join (select serial_id, Meterial_ID as mat_id, Meterial_Count from assist_bill_material_tb) g 
    on f.user_07 = g.serial_id
    where h.isstandard!=1
    group by c.factory_id, Meterial_ID) k on (k.factory_id = a.iob_adv_dep) and (k.Meterial_ID = b.material_id)
    where a.iob_kind_id = 'ASS_OUT'