首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

sql 面试有关问题

2012-07-24 
sql 面试问题?表15a1a21a1b2x2y2z用select能显示成以下结果吗?1 ab2 xyz[解决办法]ORACLE10GSQL codeCREAT

sql 面试问题?
表15
 a1 a2 
 1 a 
 1 b 
 2 x 
 2 y 
 2 z 
用select能显示成以下结果吗? 
1 ab 
2 xyz

[解决办法]
ORACLE10G

SQL code
CREATE TABLE a(a1 INT, a2 VARCHAR2(1));INSERT INTO a VALUES(1,'a');INSERT INTO a VALUES(1,'b');INSERT INTO a VALUES(2,'x');INSERT INTO a VALUES(2,'y');INSERT INTO a VALUES(2,'z');select a1, replace(wmsys.wm_concat(a2),',','') a2 from a group by a1
[解决办法]
SQL code
with tb(a1,a2) as (select 1,'a' from dualunionselect 1,'b' from dualunionselect 2,'x' from dualunionselect 2,'y' from dualunionselect 2,'z' from dual)select a1,replace(wm_concat(a2),',') as ass from tb group by a1/        A1 ASS---------- ----------         1 ab         2 xzySQL>
[解决办法]
列转行问题

热点排行
Bad Request.