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