1

私のクエリは次のようなものです:

concatenate( 
 (select col1 from table1) , ( select col1.substr(1,<tillENd>) ) 
)

両方の副選択が 1 つの行と 1 つの列を返す場合、これは正常に機能します。私の場合、どちらも複数の行を提供しますが、列は 1 つです。

それらを行ごとに連結したい。これどうやってするの?


更新: 完全なクエリは次のようなものです。

クエリ 1:

select col3 
from tabl2 
where col2 in (select substr(A,1,instr(A,'_',-1)-1) 
               from ( select substr(col1,1,instr(col1,'/')-1) as A 
                      from ( select col1 from tabl1 ) 

               ) 
           ) 

2 番目の選択クエリ:

select substr(col1,instr(col1,'/')) as A1 
from ( select col1 
from tabl1 ) 
4

3 に答える 3

8
select ...
from   ...
union all
select ...
from   ...

または、UNION ALL の代わりに UNION を使用すると、完全な結果セットが DISTINCT 操作の対象になります。

于 2012-12-20T08:39:05.673 に答える
1

いくつかのサンプル クエリを提供していただいたので、ソリューションを提供するのは簡単です。

追加の要件については、無効な文字列に一致させたくないので、サブクエリでそれらを除外するのが最も簡単だと思います。

with data as ( select substr(col1,1,instr(col1,'/')-1) as A
               , substr(col1,instr(col1,'/')) as A1 
            from tabl1
           where instr(col1,'/') > 0 )
select tabl2.col3
       , data.A1
from data
      join tabl2
     on tabl2.col2 = substr(data.A,1,instr(data.A,'_',-1)-1);
于 2012-12-20T09:18:05.063 に答える
0

LISTAGG関数を試してください。COLLECT関数も参照してください。

次に、結果を連結します。

于 2012-12-20T08:44:25.653 に答える