条件不同,可能会漏或者多而且,你是一个inner join + 上月有而本月没有的记录
漏了本月有而上月没有的记录最好用full join
insert into #lastreport        
select isnull(a.ypmc,b.ypmc) as '药品名称',
isnull(a.jxmc,b.jxmc) as '剂型',
isnull(a.ypgg,b.ypgg) as '规格',
isnull(a.ypdw,b.ypdw) as '单位',
isnull(a.cjmc,b.cjmc) as '生产厂家',
isnull(a.ghdw_mc,b.ghdw_mc) as '供货单位',        
isnull(a.ylsj,b.ylsj) as '零售价',
isnull(a.ypfj,b.ypfj) as '批发价',
isnull(a.mrjj,b.mrjj) as '进价',
isnull(a.cksl,0) as '数量',
isnull(a.pice,0) as '本月金额',    
  case when b.pice is not NULL then b.pice else 0 end as '上月金额',  
    case when a.zbbz=0 then '不招标'    
         when a.zbbz=1 then '市招标'    
         when a.zbbz=2 then '区招标'    
         when a.zbbz=3 then '区招标'    
         when a.zbbz=4 then '省招标'    
         when a.zbbz is null then
         case when b.zbbz=0 then '不招标'    
              when b.zbbz=1 then '市招标'    
              when b.zbbz=2 then '区招标'    
              when b.zbbz=3 then '区招标'    
              when b.zbbz=4 then '省招标'    
              when b.zbbz is null then null
         end             
    end as '招标方式'        
from #table1 a(nolock) full join #table01 b(nolock)                             
on a.cd_idm=b.cd_idm and a.yplb=01 and a.ypmc=b.ypmc and a.jxmc=b.jxmc and a.ypgg=b.ypgg and a.ypdw=b.ypdw      
  and a.cjmc=b.cjmc and a.ghdw_mc=b.ghdw_mc and a.ylsj=b.ylsj and a.ypfj=b.ypfj and a.mrjj=b.mrjj and a.zbbz=b.zbbz 
order by isnull(a.pice,b.price) desc