每个用户一行展示4个固定基本APN同时展示其它APN(按名称)的SQL

突然发现,上一篇选APN,是按照固定ID选出的,修改了一下,按照APN名称来选,SQL基本是一样的。

select A.MSISDN,APN4.CMNET,APN4.CMWAP,APN4.CMDM,APN4.CMMM,APNOther.APNS as "其它APN"
from XHWHB_2701_MAIN a,
(select IMSI,LISTAGG(PDPID||'|'||APN, '|') WITHIN GROUP(ORDER BY PDPID) APNS from XHWHB_2701_PDP where Upper(APN) not in ('CMNET','CMWAP','CMDM','CMMM') group by IMSI) APNOther,
(select IMSI,Max(decode(Upper(APN), 'CMNET',PDPID||'|'||APN,null)) CMNET,Max(decode(Upper(APN), 'CMWAP',PDPID||'|'||APN,null)) CMWAP,Max(decode(Upper(APN), 'CMDM',PDPID||'|'||APN,null)) CMDM,Max(decode(Upper(APN), 'CMMM',PDPID||'|'||APN,null)) CMMM from XHWHB_2701_PDP group by imsi) APN4
where (A.NAM=0 OR A.NAM=2) and A.IMSI=APNOther.IMSI(+) and A.IMSI=APN4.IMSI(+)

结果内容

Guess you like

Origin blog.csdn.net/ddrfan/article/details/104756190