首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用于计算简单利息的SQL函数

用于计算简单利息的SQL函数
EN

Stack Overflow用户
提问于 2019-05-06 19:29:42
回答 1查看 1.4K关注 0票数 0

我已经在解决方案上工作,我需要一些干预来优化解决方案。

以下是我当前的脚本:

代码语言:javascript
复制
create function SI (@Principal int, @roi int , @time int)
returns int 
as 
begin 
    declare @Principal_Amt int
    --set @Principal_Amt = 10000
    set @Principal_Amt = @Principal

    declare @rate int
    --set @rate=10
    set @rate = @roi

    declare @time_period int
    --set @time_period = 5
    set @time_period = @time

    declare @Simple_Interest int
    set @Simple_Interest = @Principal_Amt * @rate * @time_period / 100

    return @Simple_Interest
end

select dbo.SI(10000, 8, 5)
EN

回答 1

Stack Overflow用户

发布于 2019-05-06 19:34:43

这只是

代码语言:javascript
复制
create function SI(@Principal int = 0, @roi int = 0, @time int = 0)
returns int 
as 
begin 
return (@Principal * @roi * @time /100)
end

您不需要声明这些变量,因为您已经有了它们,所以可以直接使用它们。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56004327

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档