日期:2014-05-17 浏览次数:20510 次
SELECT WOO.BillID
,WOO.ID
,WOO.CallNumber
,WOO.OrderType
,WOO.OrderSubType
,WOO.DataSource
,WOO.WorkOrderCreateTime
,WOO.StaffCode
,ISNULL(CAST(QI.Total AS NCHAR),'未质检') AS Total
,ISNULL(CAST(QI.SecondTotal AS NCHAR),'未质检') AS SecondTotal
,QI.Pass
,QI.SubTime
FROM
(
SELECT WO.BillID
,WO.ID
,WO.CallNumber
,OT.[Type] AS OrderType
,OST.[Type] AS OrderSubType
,WO.DataSource
,WO.WorkOrderCreateTime
,WO.StaffCode
FROM WorkOrderTwoFit WO
LEFT JOIN OrderType OT ON WO.OrderType = OT.ID
LEFT JOIN OrderType OST ON WO.OrderSubType = OST.ID
WHERE WO.DataSource = '电话'
AND WO.StaffCode = (SELECT StaffCode FROM StaffBaseInfo WHERE StaffID = @StaffID)
AND WO.WorkOrderCreateTime >= @SDATE AND WO.WorkOrderCreateTime < @EDATE
)WOO
LEFT JOIN
(
SELECT StaffCode
,Total
,SecondTotal
,Pass
,SubTime
FROM QuaInfo
)QI
ON WOO.StaffCode = QI.StaffCode