union all

union all 和isnull

union all
union all    
SELECT      dbo.FEE_IN.ID , 
union all
cast ( 0   as   bit as  choice, 
union all
' 应收 '   as  class,
union alldbo.JOB_SE.JOBNO,
union alldbo.PD_FEEITEM.FEEITEM_CNAME, 
union alldbo.PD_COMPANY.COMP_C_CNAME, 
union alldbo.FEE_IN.CURRENCY, 
union alldbo.FEE_IN.AMOUNT,
union alldbo.FEE_IN.PRICE, 
union alldbo.FEE_IN.NUMERIC, 
union all
union alldbo.FEE_IN.FLAG_SH,
union alldbo.FEE_IN.FLAG_KP,
union all
union alldbo.FEE_IN.INVOICE_NO,
union alldbo.FEE_IN.JSMODE
union all
union all
FROM          
union alldbo.FEE_IN 
LEFT   OUTER   JOIN  dbo.PD_COMPANY 
union all
ON  dbo.FEE_IN.COMPANY_ID  =  dbo.PD_COMPANY.ID 
union all
LEFT   OUTER   JOIN  dbo.PD_FEEITEM 
union all
ON  dbo.FEE_IN.FEEITEM_ID  =  dbo.PD_FEEITEM.ID 
union all
LEFT   OUTER   JOIN  dbo.JOB_SE  
union all
ON  dbo.FEE_IN.PARENTID = dbo.JOB_SE.ID 
union all
where  dbo.FEE_IN.FLAG_SH  =   ' 1 '    and   isnull (FLAG_KP, '' ) = ' 0 '
union all
union all
union   all  
union all
union all    
SELECT      dbo.FEE_OUT.ID , 
union all
cast ( 0   as   bit as  choice, 
union all
' 应付 '   as  class,
union alldbo.JOB_SE.JOBNO,
union alldbo.PD_FEEITEM.FEEITEM_CNAME, 
union alldbo.PD_COMPANY.COMP_C_CNAME, 
union alldbo.FEE_OUT.CURRENCY, 
union alldbo.FEE_OUT.AMOUNT,
union alldbo.FEE_OUT.PRICE, 
union alldbo.FEE_OUT.NUMERIC, 
union all
union alldbo.FEE_OUT.FLAG_SH, 
union alldbo.FEE_OUT.FLAG_KP,
union all
union alldbo.FEE_OUT.INVOICE_NO,
union alldbo.FEE_OUT.JSMODE
union all
union all
FROM          
union alldbo.FEE_OUT 
LEFT   OUTER   JOIN  dbo.PD_COMPANY 
union all
ON  dbo.FEE_OUT.COMPANY_ID  =  dbo.PD_COMPANY.ID
union all 
union all
LEFT   OUTER   JOIN  dbo.PD_FEEITEM 
union all
ON  dbo.FEE_OUT.FEEITEM_ID  =  dbo.PD_FEEITEM.ID 
union all
union all
LEFT   OUTER   JOIN  dbo.JOB_SE  
union all
ON  dbo.FEE_OUT.PARENTID = dbo.JOB_SE.ID   
union all
union all
where  dbo.FEE_out.FLAG_SH  =   ' 1 '   and   isnull (FLAG_KP, '' ) = ' 0 '  
union all
union all
union all
union all ";

你可能感兴趣的:(UNION ALL)