查询重复的记录
select * from
(select count(*) as xh,id from table
group by id) where xh>1查询不重复的记录
select * from
(select count(*) as xh,id from table
group by id) where xh=1
select * from
(select count(*) as xh,id from table
group by id) where xh>1查询不重复的记录
select * from
(select count(*) as xh,id from table
group by id) where xh=1
解决方案 »
- 如何查看sql server 2008 sp1 里面解决了那些问题
- 一个小问题
- 向sql2005表中某个字段追加数据问题
- 在本机上SqlServer连接正常,但用TELNET IP 端口 就报连接失败。
- 急急急急急急!!! 关于sql 语句中如何表达‘ 这个符号的问题! 请高手指教啊!!
- sql group by的问题
- MS SQL SERVER如何传递消息给外部应用程序?
- 求救!查询问题。在线等待。
- 两台winnt4.0 server +sql server7.0 标准版拉订阅总是不成功(The inital snapshot
- SQLSERVER一个关于文件系统的问题
- 索引问题探讨研究
- 将在一个表中查的几个字段的所有内容插入到另一个表中对应的几个字段,该怎么写?
改
select count(*) as xh,id into #a from table
group by id查询重复的记录
select * from
#a
where xh>1查询不重复的记录
select * from
#a where xh=1
不过补充一点
select * from
(select count(*) as xh,id from table
group by id) as a //不加 as a 会出错
where xh>1解决了,揭帖