select sum(m.deal_qty)/count(m.deal_qty) as a, sum(m.aveprice_amt)/count(m.aveprice_amt) as b, t.short_str, m.month_date from dc_market_tproj_f m left join dc_tproject_d t on m.proj_id = t.proj_id where m.proj_id = '5DA8C46D-FF8A-4E7B-A36B-579A1F353BC2' and left(m.month_date,4) = convert(varchar(7),DATEADD(mm, -13, GETDATE()),120) group by month_date,short_str union all select sum(f.deal_qty)/count(f.deal_qty) as a, sum(f.aveprice_amt)/count(f.aveprice_amt) as b, '竞品平均' 'short_str', f.month_date from dc_cproject_form_d f left join dc_cproject_d c on f.proj_id = c.proj_id where c.tproj_id = '5DA8C46D-FF8A-4E7B-A36B-579A1F353BC2' and left(f.month_date,4) = convert(varchar(7),DATEADD(mm, -13, GETDATE()),120) group by month_date union all select sum(f.deal_qty)/count(f.deal_qty) as a, sum(f.aveprice_amt)/count(f.aveprice_amt) as b, c.proj_str 'short_str', f.month_date from dc_cproject_form_d f left join dc_cproject_d c on f.proj_id = c.proj_id where c.proj_str = '${B4}' and month_date >= convert(varchar(7),DATEADD(mm, -13, GETDATE()),120) group by month_date,proj_str
怎么在'${B4}'有值的时候使union的第二段失效? |