select id from ta group by id having count(*)>1
解决方案 »
- SQL SERVER 2000的字段值NULL真烦人,在编程时经常需要用如“Text3.Text = rst!x & ""”的形式赋值,不加“ & ""”(或用IsNull函数)程序就出错。我的看法:
- 请问:怎样返回时间里面的小时数呢?(急用)
- 关于一个DTS包的问题
- SQLSERVER sp
- 下面一段代码是用来 清空日志、收缩数据库、备份数据库的,其中BACKUP DATABASE是....
- SQL问题 跪求解答
- 有关查询语句开销超出了配置的阈值
- 急急急!我在这等着关于select的问题
- 读取汉字注释
- (sql server)一个问题~
- sql server 如何使自增长的ID归1
- 求一条SQL
if object_id('[A]') is not null drop table [A]
go
create table [A]([id] int,[name] varchar(2))
insert [A]
select 1,'tt' union all
select 2,'rr' union all
select 2,'gg' union all
select 3,'er' union all
select 4,'dd' union all
select 3,'bb' union all
select 3,'ww'
---查询---
select distinct id from [A] t where (select count(1) from A where id=t.id)>=2
---结果---
id
-----------
2
3(所影响的行数为 2 行)