查询结果中多行字段合并到一行上的SQL语句写法
CREATE TABLE temp
(
DEPTNO int,
ENAME varchar(20),
SEX varchar(20),
AGE varchar(20)
)
insert into temp values(10,'aaa','AA','18')
insert into temp values(10,'bbb','BB','19')
insert into temp values(10,'ccc','CC','20')
insert into temp values(20,'ddd','DD','21')
insert into temp values(20,'eee','EE','22')
insert into temp values(20,'fff','FF','23')
insert into temp values(30,'hhh','HH','24')
insert into temp values(30,'ggg','GG','25')
insert into temp values(30,'yyy','YY','26')
insert into temp values(30,'ttt','TT','27')
需要的查询显示结果为
10 aaa AA 18 bbb BB 19 ccc CC 20
20 ddd DD 21 eee EE 22 fff FF 23
30 hhh HH 24 ggg GG 25 yyy YY 26 ttt TT 27