2014-03-06 51 views
0

請幫我來自這導致表MSISDN和BAN列DECODE - REMOVE NULL值

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 

刪除空值。這兩列都包含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

Oracle DB 11g - NOT SURE –

+0

bu您的要求和上面的查詢不符?你究竟想要什麼?你想用上面的查詢做什麼? –

回答

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;