SELECT distinct a.FID FROM Exam_Result a
WHERE NOT EXISTS(SELECT 1 from Dict_FeeItem where id=a.fid)
 
 
 

SELECT * FROM EXAM_RESULT
SELECT TOP 20 * FROM PEIS.DBO.ExamDepartment 
SELECT TOP 20 * FROM PEIS.DBO.EnrollmentExamItem


insert into EXAM_RESULT( 
PID, SID	,DeptName,FID,	FeeItemName	,RID	,RptItemName	,TextResult, 	ItemClass ) 
SELECT 
A.ExamDepartmentId AS PID,	
A.ExamItemId as sid,
C.NAME AS DEPTNAME,
D.FeeItemId AS FID,	
D.Name AS FeeItemName,	
B.ExamItemId as rid, 
B.Name as RptItemName,
A.Name as TextResult, 
D.ItemType  as ItemClass 
FROM PEIS.DBO.ExamExamSign A
LEFT JOIN  PEIS.DBO.EnrollmentExamItem B ON A.EnrollmentExamItemId=B. ID
LEFT JOIN  PEIS.DBO.Department C ON A.DepartmentId=C.ID
LEFT JOIN PEIS.DBO.EnrollmentFeeItem D ON B.EnrollmentFeeItemId =D.ID AND D. EnrollmentId =B.EnrollmentId
WHERE A.StopOperDate IS NULL 

SELECT * FROM Dict_ReportItem WHERE ID IN (1,2,3,4,5)
select * from Exam_Result where pid in (
select id from Exam_Part where eid=1252)
SELECT * FROM Dict_FeeItem WHERE ID=3
update Exam_Result set result = convert(decimal,TextResult) where TextResult<>'' and RptItemName='身高'
SELECT DISTINCT A.ID AS EID,A.Name as Inputer,A.SignTime AS InputTime,A.FinishTime AS CheckTime,B.DeptName,C.VerifyTime FROM Enrollment_Patient A
                LEFT JOIN Enrollment_FeeItem B ON A.ID=B.EID
                LEFT JOIN Exam_Part C ON B.EID=C.EID AND B.DeptCode=C.DeptCode
                WHERE A.ID=1252

TRUNCATE TABLE EXAM_RESULT


insert into EXAM_RESULT( FID,FeeItemName,RID,RptItemName,TextResult ,DeptName ,PID ) 
SELECT  
b.feeitemid as Fid,
b.name as FeeItemName,
a.ExamItemId as Rid,
a.Name AS RptItemName,	
a.teXtvalue as TextResult, 
a.DepartmentName as DEPTNAME,
C.ID AS PID 
FROM PEIS.DBO.EnrollmentExamItem a
LEFT JOIN PEIS.DBO.EnrollmentFeeItem b ON a.EnrollmentFeeItemId =b.ID AND a. EnrollmentId =b.EnrollmentId
left join PEIS.DBO.ExamDepartment C ON a. EnrollmentId =C.EnrollmentId AND A.DepartmentId=C.DepartmentId 
ORDER BY PID


select * from 


ExamResult.FID
Dict_FeeItem.ID

  