Select 日期,价格*数量 as 产值,(select sum(价格*数量) from 价格表 a join 产量表 b
 on a.日期 = b.日期 where b.日期 <= t.日期) as 累计产值  from 价格表 j join 产量表 t on j.日期 = t.日期
where t.日期 = '2003-4-1'

解决方案 »

  1.   

    select A.日期, A.价格*B.数量 产值, 
    (select sum(A.价格*B.数量) from 价格表 A 
    inner join 产量表 B on A.日期 = B.日期
    where A.日期 <= '2003-4-1') 累计产值
    from 价格表 A inner join 产量表 B on A.日期 = B.日期
    where A.日期 = '2003-4-1'
      

  2.   

    select 价格表.日期,(价格*产值) as 产值,c.aaa from 价格表,产量表,(select sum(价格*产值) as aaa from 价格表,产量表 where 价格表.日期=产量表 .日期) as c where 价格表.日期=产量表 .日期 and 价格表.日期='2003-4-1'