减去动态列
我有一个数据库,每周都会收到新一周的数据。我希望能够获取该字段中的值并用较早一周的字段减去它们以获得一定的斜率。我需要使其尽可能自动化:
目前
最近减少:[第 13 周] - [第 9 周]
我必须每周手动更改周数,那么关于如何减少手动操作有什么建议吗?
谢谢
I have a data base where I have a new week's data coming in each week. I want to be able to take the values in that field and subtract them with an older week's field to get somewhat of a slope. I need to make this as automated as possible:
Currently have
Recent Decrease: [Week 13] - [Week 9]
I have to go in and change the weeks manually every week, so any suggestions on how to make this less manual?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我建议根据您的数据创建两个视图 - V_CURRENT 包含本周的数据,V_PREVIOUS 包含上周的数据。
然后,您可以对这两个视图执行 MINUS / UNION ALL /JOIN 操作来获取您想要的数据。
要仅在视图中获取当前和上周的数据,您必须检查如何在 RDBMS 中获取“一年中的某一周”,例如对于 Oracle:
I'd suggest creating two views based on your data - V_CURRENT containing the data of the current week, V_PREVIOUS containing the data of the last week.
Then, you can just do a MINUS / UNION ALL /JOIN with these two views to obtain the data you want.
To only get the data for the current and previous week in your views, you'll have to check how to get the "week of year" in your RDBMS, e.g. for Oracle: