请帮我从两列中删除空值
SELECT Decode(pk.property_name, 'msisdn', pv.text_value) MSISDN,
Decode(pk.property_name, 'BAN', pv.text_value) BAN
FROM PROPERTY_VALUE pv, PROPERTY_KEY pk
WHERE pv.entity_id IN
(select entity_id from property_value pv where pv.text_value in('ConsumerUnauthenticated'))
and pv.property_key_id = pk.property_key_id
这导致表MSISDN和BAN。这两列都包含NULL和NOT NULL值。我想从结果表中消除NULL。请帮忙。
BAD -
MSISDN BAN
null xyz
null abc
1213 null
null def
1211 null
我希望我的结果是
MSISDN BAN
1213 xyz
1211 abc
def
答案 0 :(得分:0)
你真的不应该这样做。检查您问题的评论。但这是查询:
SELECT MSISDN, BAN
FROM (
SELECT pv.text_value MSISDN, rownum rn
FROM PROPERTY_VALUE pv, PROPERTY_KEY pk
WHERE pv.entity_id IN (select entity_id from property_value pv where pv.text_value in('ConsumerUnauthenticated'))
AND pv.property_key_id = pk.property_key_id
AND pk.property_name = 'msisdn'
AND pv.text_value IS NOT NULL
) FULL OUTER JOIN (
SELECT pv.text_value BAN, rownum rn
FROM PROPERTY_VALUE pv, PROPERTY_KEY pk
WHERE pv.entity_id IN (select entity_id from property_value pv where pv.text_value in('ConsumerUnauthenticated'))
AND pv.property_key_id = pk.property_key_id
AND pk.property_name = 'ban'
AND pv.text_value IS NOT NULL
) USING (rn)
ORDER BY rn;