如何使用SQL语法过滤出列中的重复值?
谢谢。
虽然不确定你的意图,但如果你想要忽略重复值,那么可以列出唯一值:
SELECT col
FROM table
GROUP BY col
HAVING (COUNT(col) =1 )
如果你只想过滤掉重复项,保留它们
SELECT col, COUNT(col) AS dup_count
FROM table
GROUP BY col
HAVING (COUNT(col) > 1)
2009年,我以www.mximize.com/how-to-find-duplicate-values-in-a-table-为基础进行了操作;但现在(2014年)该网站已经不存在了。
使用DISTINCT或GROUP BY子句。
Select DISTINCT City from TableName
OR
Select City from TableName GROUP BY City
select [column] from Table1
except
select distinct [column] from Table1;
或者,您可以使用标准的SQL
。select [column] from Table1
where [column} not in
(select distinct [column} from Table1);
distinct 是用于过滤重复项的关键字。 也许您可以解释一下您想要实现什么?