2016-05-03 10 views
0

私のようなネストされたが、繰り返し機能の束とOracleでSQLクエリを使用している場合は照会:オラクルで効率的に機能を使用すると、

select trim('0' from trim(' ' from address)) 
from customers 
where 
    trim('0' from trim(' ' from address)) <> '1234 MAIN ST' and 
    trim('0' from trim(' ' from address)) <> '1234 WOOD ST' 

キャッシュのいくつかの方法/私は「するようtrim('0' from trim(' ' from address))の結果を命名があるがそれを何度も何度もやっていないのですか?このような

答えて

2

何か:

With temp as (
select trim('0' from trim(' ' from address)) col1 from customers 
) 
Select * from temp 
Where col1 <> '1234 MAIN ST' and 
     col1 <> '1234 WOOD ST' 
0

あなたはこのようクエリを書き直すことができます。

select trim('0' from trim(' ' from address)) 
from customers 
where 
    trim('0' from trim(' ' from address)) NOT IN ('1234 MAIN ST', 
                '1234 WOOD ST', 
                ... 
               ) 
1

は別名で列を作成するためにインライン・ビューを使用して、外側のクエリでそのエイリアスを参照:

select trimmed_address 
from 
(
    select trim('0' from trim(' ' from address)) trimmed_address 
    from customers 
) 
where trimmed_address not in ('1234 MAIN ST', '1234 WOOD ST'); 
関連する問題