我有以下查询:
select E.EQUIPMENT_GID, NVL((SELECT SUBSTR(ES.STATUS_VALUE_GID,INSTR(ES.STATUS_VALUE_GID, '.')+1 ) FROM EQUIPMENT_STATUS ES WHERE ES.EQUIPMENT_GID=E.EQUIPMENT_GID
AND ES.STATUS_TYPE_GID LIKE '%EQUIPMENT_STATUS' AND ROWNUM=1),'ZZZ') AS E_STATUS, NVL((SELECT EREF.EQUIPMENT_REFNUM_QUAL_GID FROM EQUIPMENT_REFNUM EREF WHERE EREF.EQUIPMENT_GID = E.EQUIPMENT_GID
AND EREF.EQUIPMENT_REFNUM_QUAL_GID LIKE '%PERMANENT DISTRICT%' and rownum=1),'ZZZ') AS PERM_DISTRICT_REF, 'PSKL-'||REPLACE(SUBSTR((SELECT EREF.EQUIPMENT_REFNUM_QUAL_GID FROM EQUIPMENT_REFNUM EREF
WHERE EREF.EQUIPMENT_GID = E.EQUIPMENT_GID AND EREF.EQUIPMENT_REFNUM_QUAL_GID LIKE '%PERMANENT DISTRICT%' AND ROWNUM=1),(INSTR((SELECT EREF.EQUIPMENT_REFNUM_QUAL_GID FROM EQUIPMENT_REFNUM EREF
WHERE EREF.EQUIPMENT_GID = E.EQUIPMENT_GID AND EREF.EQUIPMENT_REFNUM_QUAL_GID LIKE '%PERMANENT DISTRICT%' AND ROWNUM=1), '.',1,1) +1 ) ), ' PERMANENT DISTRICT','') AS DISTRICT_PSKL_XID,
**SUBSTR(E.PARK_LOCATION_GID,5,11) AS PARK_LOCATION_GID** FROM EQUIPMENT E
WHERE E.EQUIPMENT_GID=?
现在我想检查空值并将其替换为子查询中的'zzz'SUBSTR(E.PARK_LOCATION_GID,5,11) AS PARK_LOCATION_GID
任何人都可以建议解决这个问题。
答案 0 :(得分:0)
如果您使用的是sql:
,请尝试此操作SUBSTR(ISNULL(E.PARK_LOCATION_GID, 'zzz'),5,11) AS PARK_LOCATION_GID
答案 1 :(得分:0)
我明白了,应该是:
select E.EQUIPMENT_GID, NVL((SELECT SUBSTR(ES.STATUS_VALUE_GID,INSTR(ES.STATUS_VALUE_GID, '.')+1 ) FROM EQUIPMENT_STATUS ES WHERE ES.EQUIPMENT_GID=E.EQUIPMENT_GID
AND ES.STATUS_TYPE_GID LIKE '%EQUIPMENT_STATUS' AND ROWNUM=1),'ZZZ') AS E_STATUS, NVL((SELECT EREF.EQUIPMENT_REFNUM_QUAL_GID FROM EQUIPMENT_REFNUM EREF WHERE EREF.EQUIPMENT_GID = E.EQUIPMENT_GID
AND EREF.EQUIPMENT_REFNUM_QUAL_GID LIKE '%PERMANENT DISTRICT%' and rownum=1),'ZZZ') AS PERM_DISTRICT_REF, 'PSKL-'||REPLACE(SUBSTR((SELECT EREF.EQUIPMENT_REFNUM_QUAL_GID FROM EQUIPMENT_REFNUM EREF
WHERE EREF.EQUIPMENT_GID = E.EQUIPMENT_GID AND EREF.EQUIPMENT_REFNUM_QUAL_GID LIKE '%PERMANENT DISTRICT%' AND ROWNUM=1),(INSTR((SELECT EREF.EQUIPMENT_REFNUM_QUAL_GID FROM EQUIPMENT_REFNUM EREF
WHERE EREF.EQUIPMENT_GID = E.EQUIPMENT_GID AND EREF.EQUIPMENT_REFNUM_QUAL_GID LIKE '%PERMANENT DISTRICT%' AND ROWNUM=1), '.',1,1) +1 ) ), ' PERMANENT DISTRICT','') AS DISTRICT_PSKL_XID,
NVL((SUBSTR(E.PARK_LOCATION_GID,5,11)),'ZZZ') AS PARK_LOCATION_GID** FROM EQUIPMENT E
WHERE E.EQUIPMENT_GID=?