0

我有一个非常不寻常的任务,我越想我就越容易去邮局。

数据如下所示:

-----------------------------------------------------------------------------------------
| user_id | prof_org_id | prof_org_fi | prof_org_pos_fi | prof_org_en | prof_org_pos_en |
 ----------------------------------------------------------------------------------------
| 3600520 |   70000     |1100         |  as             |  1600       |   ad            |
|  1020   |   80000     |  0          |                 |     0       |                 |  
| 3600520 |   90000     | 2500        | bs              |  1700       |   bd            |
| 3600624 |   100000    |100          |   d             |  1002       |    c            |
-----------------------------------------------------------------------------------------

现在我想要的是:

------------------------------------------------
| user_id | prof_org_fi     | prof_org_en      |
 -----------------------------------------------
| 3600520 | 1100,as;2500,bs | 1600,ad;1700,bd | 
|  1020   |    0,           |   0,             |  
| 3600624 |  100,d          |  1002,c          |
------------------------------------------------

我认为它需要一些功能,不是吗?提前致谢

create table USER_MULTI_PROF_ORGS
(
  USER_ID              INTEGER not null,
  PROF_ORG_ID          INTEGER not null,
  PROF_ORG_FI          VARCHAR2(128),
  PROF_ORG_POS_FI      VARCHAR2(4000),
  PROF_ORG_EN          VARCHAR2(128),
  PROF_ORG_POS_EN      VARCHAR2(4000),
);

insert into USER_MULTI_PROF_ORGS (USER_ID, PROF_ORG_ID, PROF_ORG_FI, PROF_ORG_POS_FI, PROF_ORG_EN, PROF_ORG_POS_EN)
values (3600520, 70000, '1100', 'ad', '1600', 'ad');
insert into USER_MULTI_PROF_ORGS (USER_ID, PROF_ORG_ID, PROF_ORG_FI, PROF_ORG_POS_FI, PROF_ORG_EN, PROF_ORG_POS_EN)
values (1020, 80000, '0', null, '0', null);
insert into USER_MULTI_PROF_ORGS (USER_ID, PROF_ORG_ID, PROF_ORG_FI, PROF_ORG_POS_FI, PROF_ORG_EN, PROF_ORG_POS_EN)
values (3600520, 90000, '2500', 'bs', '1700', 'bd');
insert into USER_MULTI_PROF_ORGS (USER_ID, PROF_ORG_ID, PROF_ORG_FI, PROF_ORG_POS_FI, PROF_ORG_EN, PROF_ORG_POS_EN)
values (3600624, 100000, '100', 'd', '1002', 'c');
4

1 回答 1

0

如果您使用的是 Oracle 11g R2,请查看 LISTAGG 函数。

于 2012-07-19T08:16:03.320 回答