select a.CustomerType,substr(T.FinalEndDate,1,7) as FinalEndDate,
a.DiameterInch,a.ProductType,a.ProductCode,count(a.LotNo) as LotNo, 
sum(a.StandardQuantity) as StandardQuantity,sum(a.InputQuantity) as InputQuantity, 
sum(a.SmetalLength) as SMetalLength,sum(a.SmetalWeight) as SMetalWeight,
sum(a.PassQuantity) as PassQuantity,a.ReportType,substr(a.FinalEndDate,1,7) as Final
from cpjRptTcLotPassRate a , cpjProduct P,  
(select MorderId,FinalEndDate from cpjRptTcLotPassRate  
where  substr(FinalEndDate,1,7) in ('2003/09')  and  CustomerType='TCO') T   
where a.ProductId = P.Id
and  a.MorderId = T.MorderId  
group By a.CustomerType,substr(T.FinalEndDate,1,7) ,
a.DiameterInch,a.ProductType,a.ProductCode,
a.ReportType,substr(a.FinalEndDate,1,7);1.用到了一个临时表
2.执行时会产生死锁现象,在PB中执行没有响应。