select  b.leibiebianhao leibiebianhao,danwei
 from (
select '1' type,anjianbianhao,shoulingdanwei danwei,'1' leixing,xuyaofankui from view_an_qing_xin_xi_father 
where BAOJINGSHIJIAN between (to_date('2005-05-26 00:00:00','yyyy-mm-dd hh24:mi:ss') , to_date('2005-05-26 23:59:59','yyyy-mm-dd hh24:mi:ss')) and shoulingdanwei is not null 
union
select '2' type,anjianbianhao,fankuidanwei danwei,'2' leixing,null xuyaofankui from view_an_qing_xin_xi_father
where between (to_date('2005-05-26 00:00:00','yyyy-mm-dd hh24:mi:ss') , to_date('2005-05-26 23:59:59','yyyy-mm-dd hh24:mi:ss'))  and fankuidanwei is not null 
) a,dan_wei_ming_cheng b
where a.danwei = b.bianhao