利差的计算
2004-07-01 16:23
561 查看
在一般的数据库设计中,一般无法保留客户每天的资金情况,一般只保留资金增量表,但因为利息积数是每天变化,故保留的利息积数也是资金变化当日的利息积数,计算利差可不能简单的采用增量表中的利息积数。
开始考虑,对每天的利差:
round(a.balance * 企业利率/360,2) - round(a.balance * 个人利率/360,2)
但个人利率实际是不相同的,故很多时候不能直接使用个人利率,而直接采用利息计算
round((a.interest_acc - coalesce(b.interest_acc,0.00)) * 企业利率/360,2)
- (a.pending_interest - coalesce(b.pending_interest,0.00))
a为当天余额表,b为前一交易日余额表
可是上面的算法还是有问题,如果存在结息就麻烦了
case when a.interest_acc<=b.interest_acc then round(a.interest_acc*企业利率/360,2)-a.pending_interest
else round((a.interest_acc - coalesce(b.interest_acc,0.00)) * 企业利率/360,2)
- (a.pending_interest - coalesce(b.pending_interest,0.00))
这个只对全部结息有效,对部分结息又没办法了。
开始考虑,对每天的利差:
round(a.balance * 企业利率/360,2) - round(a.balance * 个人利率/360,2)
但个人利率实际是不相同的,故很多时候不能直接使用个人利率,而直接采用利息计算
round((a.interest_acc - coalesce(b.interest_acc,0.00)) * 企业利率/360,2)
- (a.pending_interest - coalesce(b.pending_interest,0.00))
a为当天余额表,b为前一交易日余额表
可是上面的算法还是有问题,如果存在结息就麻烦了
case when a.interest_acc<=b.interest_acc then round(a.interest_acc*企业利率/360,2)-a.pending_interest
else round((a.interest_acc - coalesce(b.interest_acc,0.00)) * 企业利率/360,2)
- (a.pending_interest - coalesce(b.pending_interest,0.00))
这个只对全部结息有效,对部分结息又没办法了。
相关文章推荐
- 将15位身份证补全为18位身份证的算法示例详解
- C++算法系列之日历生成的算法代码
- 千年零一虫
- c#接简单数据库操作类
- 独具量身定做特色的管理软件--数据大师
- 发现数据对象--数据库开发的关键
- 非对称加密算法中求解大正整数模大正整数的余数的快速计算法
- 用VB和MTS开发多层数据库应用系统
- 纯编码实现数据库的建立或压缩
- 从数据库中动态选取下拉列表的方法
- Decal SDL-Delphi的范型类库-通用数据结构与算法类库(一)
- 关于FSO静态生成技术的应用范围之解决思路
- XML的QL查询语言及其实现
- XML的QL查询语言及其实现-2
- 我的php的一个数据库的操纵类
- 三、ATM的传输控制
- 提出一种密钥生成方案
- 用VxD技术设计网络计费系统
- P=NP?问题简介
- 让计算机开口说话