我想在我的ItemDescription列中找到单个单词的重复项。请看图片:https://imgur.com/oxuaSJT。不是重复的值,而是值中包含单个单词的重复项。可能吗?请帮我。
答案 0 :(得分:1)
使用GROUP BY
运算符查找出现的单词,并使用HAVING
和SELECT
i.ItemDescription
FROM dbo.tbiitems i
WHERE i.ItemDescription LIKE '%NR%' OR i.ItemDescription LIKE '%NRCONDITIONER%' OR
i.ItemDescription LIKE '%CREAMBATH%'
GROUP BY i.ItemDescription
HAVING COUNT(i.ItemDescription) > 1
运算符查找重复项:
ItemDescription
或者如果您想查找SELECT
i.ItemDescription, COUNT(i.ItemDescription) AS CountItemDescription
FROM dbo.tbiitems i
WHERE i.ItemDescription LIKE '%NR%' OR i.ItemDescription LIKE '%NRCONDITIONER%' OR
i.ItemDescription LIKE '%CREAMBATH%'
GROUP BY i.ItemDescription
HAVING COUNT(i.ItemDescription) > 1
的计数并遵循 SQL规则 this subject on SO for example(感谢@Daniel E。):
A