如何获取总天数报告构建器(Oracle DB)
从特定日期开始,我有一段时间用于总库存的报告。但是,我需要添加一列,以显示该材料已经存在了多少天。我该如何完成?
假设我的查询是:
MVT.INVT_LEV1,
MVT.INVT_LEV2,
MVT.INVT_LEV3,
MVT.INVT_LEV4,
INVT_ORG_RECD_DATE
FROM M_INVT
INVT_ORG_RECD_DATE提供了收到材料中库存的日期。假设数据为07/05/22。我想要另一篇文章,说库存已经存在了两天。我该如何完成?如果这没有意义,我可以在整个查询中复制。
我想象第一个日期是该列中的日期,第二个日期是我正在运行报告的日期?还有一些系统需要如何弄清两者之间有多少天?
I have a report we have been using for quite some time for total inventory as of a specific date. However, I need to add a column that shows how many days this material has been in inventory. How do I accomplish this?
Let's say my query is:
MVT.INVT_LEV1,
MVT.INVT_LEV2,
MVT.INVT_LEV3,
MVT.INVT_LEV4,
INVT_ORG_RECD_DATE
FROM M_INVT
INVT_ORG_RECD_DATE provides the date the material was received into our inventory. Let's say the data is 07/05/22. I want another column that says inventory has been with us for two days. How do I accomplish this? If this doesn't make sense I can copy over my entire query.
I would imagine the first date is the date in that column, and the second date would be the date I am running the report for? and some how need to system to figure out how many days in between?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
最简单的选项是在查询中进行计算:
为什么
trunc
?因为sysdate
返回日期和时间,因此您将获得分数数:另一个选择是在数据模型编辑器中创建公式列(单击适当的按钮在左侧工具栏中,并将其添加到包含其他字段的组中)。将其命名,例如
cf_number_of_days
并编辑其属性;您要使用的代码将是公式列表示返回一些值的函数(在您的情况下为数字)。
最后,将新字段添加到纸质布局编辑器中。我想你知道该怎么做。
The simplest option is to do the calculation within the query:
Why
TRUNC
? Becausesysdate
returns both date and time, so you'd get fractional number of days:Another option is to create a formula column in the Data Model Editor (click the appropriate button in the left-hand side toolbar and add it into the group that contains other fields). Name it e.g.
CF_NUMBER_OF_DAYS
and edit its properties; code you'd use would beas formula column represents a function that returns some value (a number, in your case).
Finally, add the new field into the Paper Layout Editor. I guess you know how to do that.