我的桌子:
CREATE TABLE [dbo].[Balance] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[Balance] DECIMAL (18, 2) NOT NULL,
[Today_Date] AS (CONVERT([char](10),getdate(),(126))),
[Date_end] DATE NOT NULL,
[Remaining_Days] AS (datediff(day,CONVERT([char](10),getdate(),(126)),[Date_end])),
[In_Months] AS (datediff(day,CONVERT([char](10),getdate(),(126)),[Date_end]))/(30),
[Amount_Monthly] AS CAST((case when ((datediff(day,CONVERT([char](10),getdate(),(126)),[Date_end]))/30) = 0 then NULL else [Balance]/((datediff(day,CONVERT([char](10),getdate(),(126)),[Date_end]))/30) end) as DECIMAL(18,2)),
PRIMARY KEY CLUSTERED ([Id] ASC)
);
它的样子:
我希望它自动将Amount_Monthly 插入一个新表中,所以它看起来像这样:
例如,如果它说 In_Months = 2 它应该填写一月和二月的 Balance_monthly 至 7058,82。我希望它自动计算它就像我让它根据输入自动计算剩余天数一样。
谢谢!