商品每日交易信息表A中有属性Date,商品id,成交量number,当日价格price,需要以视图表示商品信息以及前一天的价格,与今日价格的差和价格变化的百分比,自己写的sql语句如下,执行以后没有结果,求各位指教。
create or replace view A("Date",id,number, PrePrice, Price, Change, Percent) as
select a."Date",a.id,a.Volume,b.Price,a.Price,(a.price-b.price),((a.price-b.price)/b.price*100)
from A a,A b
where b.Price in (select b.Price
from A b
where b."date"=a."date"-1 and a.code=b.code)
;