在sqlserver中: create function fnGetName( @sXh varchar(20) ) returns varchar(200) as begin declare @sName varchar(200) set @sName=''; select @sName = @sName + sName from test where xh=@sxh return @sName )select xh from ( select distinct xh,sName=fnGetName(xh) from test ) a group by xh having count(*)>1
我就想查出这样的情况!
1 abc
2 bcd
3 fbc
然后在此基础上,再查组合字段一样的
看上面那个帖子,
将表变成:
xh name
1 abc
2 cdb
3 fbc
4 abc
然后直接判断 name 就可以。
create function fnGetName( @sXh varchar(20)
) returns varchar(200) as
begin
declare @sName varchar(200)
set @sName='';
select @sName = @sName + sName from test where xh=@sxh
return @sName
)select xh from (
select distinct xh,sName=fnGetName(xh) from test
) a group by xh having count(*)>1