帮忙写个SQL,多谢

帮忙写个SQL,谢谢create table test(a int,b char,c char)insert into test values(1,a,b)insert into

帮忙写个SQL,谢谢
create table test(
a int,
b char,
c char
)

insert into test values(1,'a','b')

insert into test values(2,'a','b')

insert into test values(3,'b','c')

要得到如下结果(请考虑如果有多行相同的数据):
a b c
----------- ---- ----
1 a b
2 a b



[解决办法]

SQL code
;with cte as (select b,c,count(1) num from testgroup by b,c having count(1)>1)select * from test t where exists(select 1 from cte where b=t.b and c=t.c)
[解决办法]
SQL code
SELECT  A.*FROM    test A        INNER JOIN ( SELECT b ,                            c                     FROM   test                     GROUP BY b ,                            c                     HAVING COUNT(1) > 1                   ) T ON A.b = T.b                          AND A.c = T.c