查询的第一部分在not in运行之前为我提供了100条记录的列表。第二个查询运行,并提供75条记录的列表。我尝试使用的查询not in是获取一个结果集中的记录,而不是另一个。我得到的错误是incorrect syntax near the word not。
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?
expression AND NOT IN (select query
您需要指定第二个查询中没有的字段
and Patient.patientid not in