运行前查询的第一部分not in
给了我一个包含 100 条记录的列表。第二个查询运行并给我一个包含 75 条记录的列表。我尝试使用的查询not in
是获取一个结果集中的记录,而不是另一个结果集中的记录。我得到的错误是incorrect syntax near the word not
.
SELECT distinct Patient.patientid
FROM Patient INNER JOIN
patientICD ON Patient.patientid = patientICD.patientid AND Patient.admissiondate = patientICD.admissiondate AND
Patient.dischargedate = patientICD.dischargedate INNER JOIN
tblICD ON patientICD.primarycode = tblICD.ICD_ID
WHERE (tblICD.descrip LIKE N'%diabetes%') and not in
(
SELECT distinct Patient.patientid
FROM Patient INNER JOIN
patientICD ON Patient.patientid = patientICD.patientid AND Patient.admissiondate = patientICD.admissiondate AND
Patient.dischargedate = patientICD.dischargedate INNER JOIN
tblICD ON patientICD.primarycode = tblICD.ICD_ID
WHERE (tblICD.icd_id LIKE N'25000')
)
是否允许使用 编写查询expression AND NOT IN (select query
?