1.这里假如日期是字符型:
select 日期,金额-isnull((select top 1 金额 from t where 日期<a.日期 order by 日期 desc),0) 金额
from t a
select 日期,金额-isnull((select top 1 金额 from t where 日期<a.日期 order by 日期 desc),0) 金额
from t a
From table
select * from 第一个表
union all select * from 第二个表
我就是不知道在SQL中怎么写case/if语句了