我正在使用以下代码创建一个表,我没有太多列,但仍然出现错误
Create table corrYear as
Select a.Symbol ASymbol,b.Symbol BSymbol, corr(a.logp,b.logp) Correlation
From logprofitDEC a join logprofitDEC b
on a.Tdate=b.Tdate
where a.Symbol>b.symbol
And a.symbol in (select asymbol,bsymbol from pairDec1st2nd)
And b.symbol in (select asymbol,bsymbol from pairDec1st2nd)
And To_date(a.Tdate,'YYYYMMDD') between DATE'2013-01-01' AND DATE'2013-12-31'
And To_date(a.Tdate,'YYYYMMDD') between DATE'2013-01-01' AND DATE'2013-12-31'
group by a.symbol,b.Symbol;
错误是
00913.00000-"too many values"
我不知道为什么,通常这是由太多列引起的。该怎么办?
答案 0 :(得分:5)
我的猜测是导致错误的是这些行:
And a.symbol in (select asymbol,bsymbol from pairDec1st2nd)
And b.symbol in (select asymbol,bsymbol from pairDec1st2nd)
在这两种情况下,subselect返回两列,其中应该只有一列如此:
And a.symbol in (select asymbol from pairDec1st2nd)
And b.symbol in (select bsymbol from pairDec1st2nd)
如果我记得正确的Oracle允许IN谓词中有多个列,如下所示:
And (a.symbol, b.symbol) in (select asymbol,bsymbol from pairDec1st2nd)
虽然我不确定最后一个。