create table 表(部门 int,人员 varchar(20)) insert into 表 select 1,'张三' insert into 表 select 1,'李四' insert into 表 select 1,'王五' insert into 表 select 2,'赵六' insert into 表 select 2,'邓七' insert into 表 select 2,'刘八' go--创建用户定义函数 create function f_str(@department int) returns varchar(8000) as begin declare @ret varchar(8000) set @ret = '' select @ret = @ret+','+人员 from 表 where 部门 = @department set @ret = stuff(@ret,1,1,'') return @ret end go --执行 select 部门,人员=dbo.f_str(部门) from 表 group by 部门 order by 部门 go--输出结果 /* 部门 人员 ---- -------------- 1 张三,李四,王五 2 赵六,邓七,刘八
用EasyGrid每一行要在设计中加入,根本不行
insert into 表 select 1,'张三'
insert into 表 select 1,'李四'
insert into 表 select 1,'王五'
insert into 表 select 2,'赵六'
insert into 表 select 2,'邓七'
insert into 表 select 2,'刘八'
go--创建用户定义函数
create function f_str(@department int)
returns varchar(8000)
as
begin
declare @ret varchar(8000)
set @ret = ''
select @ret = @ret+','+人员 from 表 where 部门 = @department
set @ret = stuff(@ret,1,1,'')
return @ret
end
go
--执行
select 部门,人员=dbo.f_str(部门) from 表 group by 部门 order by 部门
go--输出结果
/*
部门 人员
---- --------------
1 张三,李四,王五
2 赵六,邓七,刘八
http://topic.csdn.net/t/20051111/10/4386462.html
那篇文章是说StringGrid的合并,不是DBGRID
第一、空的单元格会显示边线
第二、当拉动滚过条时,最上一格可能显示空白。我看过很多用PB开发的程序,这个效果好象很容易实现,我没用过PB,请大家指教。
+ Added property HideDuplicates: Boolean in TColumnEh. Determines whether to hide
duplicated values in the column.