0

我想创建表并使用两个,这是我的代码:

Create Table profitTry
As
With ctsWithSplit as (select c.Tdate, c.Symbol, c.close * coalesce(s.post/s.pre, 1) as new_close
 from ctsTry c left join splits s 
on c.Tdate = s.Tdate and c.symbol = s.symbol),

delta as
( select a.Tdate as TDate,  a.Symbol as Symbol, a.price-b.price as Pdelta, b.price as oldPrice
   from ctsWithSplit a, ctsWithSplit b
   where a.TDate-b.TDate=1 and a.Symbol=b.Symbol)

select  a.TDate,a.Symbol, (a.delta-coalesce(b.dividend,0))/delta.oldPrice as percentage
From delta a left join dividend b
On a.Tdate=b.Tdate and a.Symbol=b.Symbol

有一个错误说“表不存在”,是因为我的第二个 with 子句吗?

4

1 回答 1

1

一个明确的问题在于您的外部select

select  a.TDate,a.Symbol, (a.delta-coalesce(b.dividend,0))/delta.oldPrice as percentage
-----------------------------------------------------------^
From delta a left join dividend b
On a.Tdate=b.Tdate and a.Symbol=b.Symbol

没有delta。你的意思是a

于 2015-02-20T00:36:57.327 回答