取出相同记录的问题
declare @t table (id int,name varchar(20),level int)
insert into @t select 1,'a',3
union all select 2,'a',7
union all select 3,'a',9
union all select 4,'a',4
union all select 5,'b',4
union all select 6,'b',13
union all select 7,'c',13
union all select 8,'c',15
想取出level相同的记录
得如下结果
id name level
4 a 4
5 b 4
6 b 13
7 c 13
问题点数:20、回复次数:2Top
1 楼jdcyongshi()回复于 2005-11-18 18:58:25 得分 1
用自身连接的子查询
Top
2 楼scmail81(琳·风の狼(修罗))回复于 2005-11-18 19:36:26 得分 19
declare @t table (id int,name varchar(20),level int)
insert into @t select 1,'a',3
union all select 2,'a',7
union all select 3,'a',9
union all select 4,'a',4
union all select 5,'b',4
union all select 6,'b',13
union all select 7,'c',13
union all select 8,'c',15
select * from @t where level in(select level from @t group by level having count(*)>1)Top




