如何在同一SQL表中的本月数据中的下个月更新现有行?

发布于 2025-02-09 03:41:09 字数 2444 浏览 1 评论 0原文

I have one SQL table called Employee_invoice

JobSiteNameInvocieDateInvoiceAmountCrew_size
J003297David3/1/2022160010
J003297Jhon5/1/2022200020
J102899Andy12/1/2022400030
J003297Olive22/1/2022200045
J003297David3/2/202200
J003297JHON5/2/202200
J102899ANDY ANDY12/2/202200
J003297OLIVE22/2/20220 00,

所以我想更新InvoiceAceamount,下个月的Crew_size Poind ie ie ie ie c。一个月,即一月。联接条件将在工作地点和名称列上匹配。

我想要为此存储的过程,该过程将每月运行第一天,并更新多列。 (@tableType)

结果表应该看起来像这样:

I have one SQL table called Employee_invoice

JobSiteNameInvocieDateInvoiceAmountCrew_size
J003297David3/1/2022160010
J003297Jhon5/1/2022200020
J102899Andy12/1/2022400030
J003297Olive22/1/2022200045
J003297David3/2/202200
J003297Jhon5/2/202200
J102899Andy12/2/202200
J003297Olive22/2/202200

So I want to update InvoiceAmount, Crew_size column of next month i.e. February based Previous month i.e. January month. The join condition will be matched on JobSite and Name column.

I want a stored procedure for this, which will run 1st day of every month and update multiple columns. (@Tabletype)

The result table should look like this:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文