如何从一列获取唯一数据?

时间:2014-11-04 05:38:48

标签: sql sql-server

假设我有以下专栏:

+------+
| id   |
+------+
|1500  | 
|1500  |
|1600  |
|1700  |
|1700  |
|1700  |
|1800  | 
+------+

我的问题是我只想显示列中显示的ID一次,怎么做?

结果将是1600& 1800

2 个答案:

答案 0 :(得分:1)

SELECT ID FROM YourTable
GROUP BY ID 
Having Count(*) = 1

试试上面的

答案 1 :(得分:0)

select id  from tablename
group by id
Having Count(id) = 1