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');
這和[昨天的問題](http://stackoverflow.com/q/11538816/266304)是不是很相似?在執行'listagg'之前,您只需要將兩個列連接在一起。你真的需要表現出一些努力,如果有人給你提供解決方案,你就不會學到任何東西,你也不會去理解和適應它。 – 2012-07-19 07:11:23
謝謝亞歷克斯。是的,串接是我所缺少的。 – Jaanna 2012-07-19 07:23:33