use Test
go
 SELECT 
  MOCTF.TF001+'-'+MOCTF.TF002 as 生产入库单号
 ,MOCTF.TF003 as 入库日期
 ,MOCTG.TG004 as 品号
 ,MOCTG.TG005 as 品名
 ,MOCTG.TG006 as 规格
 ,MOCTG.TG007 as 单位
 ,MOCTG.TG011 as 数量
 ,MOCTA.TA026+'-'+MOCTA.TA027+'-'+MOCTA.TA028 as 订单单号
 ,COPTD.TD011 as 售价
 ,COPTC.TC009 as 汇率 
 ,MOCTG.TG011*COPTD.TD011*COPTC.TC009 as 金额
FROM MOCTF  
 Left JOIN MOCTG On MOCTF.TF001=MOCTG.TG001 and MOCTF.TF002=MOCTG.TG002 
 Left JOIN MOCTA On MOCTG.TG014=MOCTA.TA001 AND MOCTG.TG015=MOCTA.TA002 
 Left JOIN COPTD On MOCTA.TA026=COPTD.TD001 AND MOCTA.TA027=COPTD.TD002 AND MOCTA.TA028=COPTD.TD003 AND MOCTA.TA006=COPTD.TD004  
 left join COPTC on TC001+TC002=TD001+TD002
 WHERE 
     MOCTF.TF006 = 'Y' 
     AND MOCTG.TG022 = 'Y' 
     and TF001 = '5804'  --入库单别
     and TF003 like '201806%'  --入库月份
     and COPTD.TD011 is not null   --清除NULL