--Change为自定义较上期的变化值
select NoteID,code,UpdateTime,Balance
,Change=Balance-
(
--根据主查询t1得出的代码和时间作为条件获得小于最大日期的上期max(UpdateTime)日期的额度Balance值
select Balance from SMS_FillMonenyNote where code=t1.code and 
UpdateTime=(select max(UpdateTime) from SMS_FillMonenyNote 
where code=t1.code and UpdateTime<t1.UpdateTime)
from SMS_FillMonenyNote as t1 
--根据not exists找出不存在有大于NoteID的t1.NoteID,也就是最大的NoteID
where not exists (select * from SMS_FillMonenyNote where code=t1.code
and NoteID>t1.NoteID)
order by code

相关文章:

  • 2021-12-17
  • 2022-03-05
  • 2022-12-23
  • 2022-12-23
  • 2021-04-08
  • 2022-12-23
  • 2021-10-15
猜你喜欢
  • 2021-12-22
  • 2022-12-23
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案