我正在尝试在MS Access中编写一个sql:
我有一个包含列(id,Name,code)
的表我需要选择具有相同名称的所有记录多次出现,其中行之间不存在代码为IS NULL的行
我试过这个但是没有用
SELECT Name
FROM TableName
GROUP BY Name
HAVING NOT EXISTS ( Select Name FROM TableName Where code IS NULL Group By Name Having COUNT(*) > 1) ;
答案 0 :(得分:1)
SELECT Name
FROM TableName
GROUP BY Name
HAVING sum(IIF(code is null OR code = 0, 1, 0)) = 0
AND COUNT(*) > 1