ORACLE数据生成具有唯一值的列作为主键可以使用SYS_GUID()方法;
SELECT
SYS_GUID() AS ID,
DECODE(U.ID, NULL, Z.ZTNAME, D.DEPARTMENTNAME) ZTNAME,
Z.YEARV YEARV,
Z.KMCODE KMCODE,
Z.KMNAME KMNAME,
DECODE(U.ID, NULL, Z.ZTCODE, D.EXT4) ZTCODE,
DECODE(Z.ZTTYPE, '人员档案','部门档案', Z.ZTTYPE) ZTTYPE,
SUM(Z.YSAMOUNT) YSAMOUNT,
SUM(Z.ZFWC) ZFWC,
SUM(Z.BDGCOMP) BDGCOMP,
SUM(Z.NEWZFWC) NEWZFWC,
SUM(Z.NEWBDGCOMP) NEWBDGCOMP,
SUM(Z.TOT) TOT,
SUM(Z.MEABDGCOMP) MEABDGCOMP,
SUM(Z.BALANCE) BALANCE,
SUM(Z.ZFZT) ZFZT,
SUM(Z.NEWZFZT) NEWZFZT,
MAX(Z.DEPARTMENTNAME) DEPARTMENTNAME,
MAX(Z.DEPTMGR) DEPTMGR,
MAX(Z.DEPTMGRID) DEPTMGRID
FROM
VIEW_ACT_CSTBDGT_MONITOR_T Z
LEFT JOIN ORGUSER U ON Z.ZTCODE = U.EXT5
LEFT JOIN ORGDEPARTMENT D ON U.DEPARTMENTID = D.ID
GROUP BY
DECODE(U.ID, NULL, Z.ZTNAME, D.DEPARTMENTNAME),
Z.YEARV,
Z.KMCODE,
Z.KMNAME,
DECODE(U.ID, NULL, Z.ZTCODE, D.EXT4),
DECODE(Z.ZTTYPE, '人员档案','部门档案', Z.ZTTYPE)
但SYS_GUID()方法返回的是raw值,故还要使用RAWTOHEX()方法将RAW值转为16进制值
否则会出现乱码
RAWTOHEX(SYS_GUID()) AS ID,