前段時間使用ORACLE
Sql代碼
建表語句
create table SP_ALERT_PA_GROUP
(
ID INTEGER not null
ALERTCODE VARCHAR
PAINNERCODE VARCHAR
)
insert into sp_alert_pa_group (ID
values (
insert into sp_alert_pa_group (ID
values (
insert into sp_alert_pa_group (ID
values (
insert into sp_alert_pa_group (ID
values (
要求顯示的結果
ALERTCODE PAINNERCODE
AL
AL
Sql代碼
CREATE OR REPLACE FUNCTION getpa(alertcode VARCHAR
RETURN VARCHAR
IS
pastr VARCHAR
BEGIN
FOR cur IN (SELECT painnercode FROM sp_alert_pa_group WHERE alertcode=alertcode) LOOP
pastr := pastr||cur
END LOOP;
RETURN pastr;
END;
然後使用下面的SQL查詢即可!
SELECT DISTINCT alertcode
Sql代碼
SELECT wmsys
這個簡單明了
Sql代碼
select substr(max(sys_connect_by_path(painnercode
from (select a
start with rn=
connect by rn
From:http://tw.wingwit.com/Article/program/Oracle/201311/16949.html