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, 
**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

任何人都可以提出解决方案。

4

2 回答 2

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=?
于 2013-05-29T18:42:29.687 回答
0

如果你使用 sql 试试这个:

SUBSTR(ISNULL(E.PARK_LOCATION_GID, 'zzz'),5,11) AS PARK_LOCATION_GID
于 2013-05-28T16:25:17.787 回答