
update peisdb.[dbo].[Exam_Result] set TextResult=tt.TextResult
from
(
	select t.id,t2.TextResult from peisdb.dbo.Exam_Result t  
	left join 
	( 
			SELECT  
						 C.Id AS PID
						,B.DepartmentId AS [DID]
						,A.DepartmentName AS [DeptName]
						,A.[FeeItemId] AS [FID]
						,A.Name AS FeeItemName
						,B.[ExamItemId] AS [RID]
						,B.[Name]   AS [RptItemName]
						,B.[TextValue] AS [TextResult]
						,B.[ValueUnit]  AS [Unit] 
				,A.ItemType AS [ItemClass]
				,B.LisCode AS RPTITEMCODE
				,B.LisRange AS [Range]
				,B.LisVerifyOperName	AS REPORTER
				,B.LisVerifyOperDate AS REPORTTIME
				,B.	LisFlag AS  UnusualFlag 
			 FROM  PEIS.DBO.[EnrollmentApplicationSheetFeeItem] A (NOLOCK)
			 JOIN  PEIS.DBO.[EnrollmentExamItem] B (NOLOCK) ON A.Id = B.EnrollmentApplicationSheetFeeItemId
			 JOIN  PEIS.DBO.[ExamDepartment] C(NOLOCK) ON B.DepartmentId = C.DepartmentId AND B.EnrollmentId = C.EnrollmentId AND A.EnrollmentId  =C.EnrollmentId 
			WHERE A.SendOperDate IS NOT NULL AND A.RemoveOperDate IS NULL AND B.RemoveOperDate IS NULL AND C.RemoveOperDate IS NULL  
							AND A.GiveUpOperDate IS NULL AND B.GiveUpOperDate IS NULL
							
			) as t2  on t2.pid=t.pid and t2. RptItemName	=t.RptItemName and t2.FeeItemName=t.FeeItemName 
			where (t.TextResult is null or t.TextResult='')and (t2.TextResult <>'') 
) tt
where Exam_Result.id=tt.id  
 
 