s_id name
1 a
2 b
3 a
2 b
4 c
6 t
7 r
8 t
9 q
10 m
10 c
11 g_________________删除所有name只关联一个s_id记录怎么写?
1 a
2 b
3 a
2 b
4 c
6 t
7 r
8 t
9 q
10 m
10 c
11 g_________________删除所有name只关联一个s_id记录怎么写?
解决方案 »
- sqlser服务管理器中的服务器名称存储在什么地方?
- 关于sql2005的超时问题
- 多表修改问题材
- 实体联系图问题,多个实体之间的联系,求解,相当纠结……长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标题长标长标题长标题长标题
- 一个SQL server 2000的问题
- 关于MSDE用企业管理器的问题
- 向 all,dawugui,小梁子,邹老大求组--group by中第二列的连接问题!
- 关于多表删除的问题
- 如何将两张表中的数据进行合并,注意不是做笛卡儿积或自然连接或θ连接
- 如何獲得一個數据庫的所有触發器
- 关于一个交叉表的问题
- asp.net3.5的程序要iis多少才能看见啊,还有就是自己的服务器比如221.252.2.12如何配置,就可以让网络上的人访问
where name in(select namem from tb group by name having count(1)=1)
from ta a
where exists(select 1 from ta where name = a.name and s_id < a.s_id)
小f??
为什么是count(1)了???
group by 以后可以用 count(1) 这个地方count(1)=count(name)
统计同一个name的s_id个数
declare @table table(id int,name varchar(50))
insert into @table
select 1 , 'a'
union all select 2, 'b'
union all select 3, 'a'
union all select 5 , 'b'
union all select 4 , 'c'
union all select 6 , 't'
union all select 7 , 'r'
union all select 8 , 't'
union all select 9 , 'q'
union all select 10 ,'m'
union all select 10, 'c'
union all select 11,'g' select * from @tabledelete A from @table a where not exists(select * from @table
where name=a.name and id<>a.id)
select * from @table