日期:2014-05-17 浏览次数:20498 次
SELECT ContactId FROM Contact WHERE ContactId IN测试了一下,有些问题,就是说如果字段值为NULL的时候
(SELECT contactId FROM Contact c,
(SELECT AccountId,ContactName FROM Contact GROUP BY AccountId,ContactName HAVING count(*)>1) AS #tmp
where c.AccountId=#tmp.AccountId AND c.ContactName=#tmp.ContactName)
AND ContactId NOT IN(SELECT Max(ContactId) FROM Contact GROUP BY AccountId,ContactName HAVING count(*)>1);
c.AccountId=#tmp.AccountId AND c.ContactName=#tmp.ContactName这个判断就取不到数据了,因为要用 is NULL来判断,现在求大神可否解决此问题或者提供更好的方法,在线等,急!!
SELECT ContactId FROM Contact as a where not exists (select 1 from Contact as b on a.AccountId=b.AccountId and a.ContactName=b.ContactName and b.ContactId>a.ContactId)
c.AccountId=#tmp.AccountId AND c.ContactName=#tmp.ContactName
isnull(c.AccountId,'')=isnull(#tmp.AccountId,'') AND isnull(c.ContactName,'')=isnull(#tmp.ContactName,'')