物化视图中的动态计算
我有一个问题,我创建了一个完美运行的物化视图。但现在我需要用我认为的数据进行一些计算。该视图包含在不同项目中工作的员工的工作时间。每个项目都有员工必须完成项目的固定时间 (time_available)。为了更好地展示,我将工作时间汇总为每月。我想要在这里完成的是“简单”减去“项目的固定金额”减去员工的“工作时间”。 这里的问题是有些项目的持续时间超过一个月。当然,我每个月的所有值都在一个元组中。因此,当我的项目有 3 个月的工作时间时,我的视图如下所示:
MV_Working_Hours:
Project --- Time_Available --- DATE --- Employee --- Working Days
Project A --- 50 Days --- 2011-05 --- Mr. A --- 15 Days
Project A --- 50 Days --- 2011-06 --- Mr. A --- 16 Days
Project A --- 50 Days --- 2011-07 --- Mr. A --- 16 Days
我想要做的是计算剩余天数,如下所示:
Project --- Time_Available --- DATE --- Employee --- Working d in Month ---remaining days
Project A --- 50 Days --- 2011-05 --- Mr. A --- 15 Days --- 35 Days
Project A --- 50 Days --- 2011-06 --- Mr. A --- 16 Days --- 19 Days <--- I get here 34 which is for my need wrong !!!
Project A --- 50 Days --- 2011-07 --- Mr. A --- 16 Days --- 3 Days
有没有一种方法可以用“仅”sql 来实现这一点,或者我有在 OWB 中使用 pl/sql?我使用 OWB 版本 11gR2
谢谢
I have a problem I created a materialized view which works perfectly. But now I need to perform some calculations with the data in my view . The view contains the working hours of employees who worked in different projects. Every project has a fixed amount of time (time_available) in which the employee has to finish the project. I aggregated the working hours to month for better presentation. What I want to accomplish here is a "simple" subtraction of "fixed amount for a project" minus "working hours" for the employee.
The problem here is that some project have duration of more that just one month. Naturally all my values are in one tuple for every month. So when I have 3 month of working hours for a project my view looks like this:
MV_Working_Hours:
Project --- Time_Available --- DATE --- Employee --- Working Days
Project A --- 50 Days --- 2011-05 --- Mr. A --- 15 Days
Project A --- 50 Days --- 2011-06 --- Mr. A --- 16 Days
Project A --- 50 Days --- 2011-07 --- Mr. A --- 16 Days
What I want to do is to calculate the remaining days like this :
Project --- Time_Available --- DATE --- Employee --- Working d in Month ---remaining days
Project A --- 50 Days --- 2011-05 --- Mr. A --- 15 Days --- 35 Days
Project A --- 50 Days --- 2011-06 --- Mr. A --- 16 Days --- 19 Days <--- I get here 34 which is for my need wrong !!!
Project A --- 50 Days --- 2011-07 --- Mr. A --- 16 Days --- 3 Days
Is there a way to realize this with "just" sql or do I have to use pl/sql in the OWB? I use the OWB version 11gR2
thx
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该能够使用分析函数来生成运行总计。像这样的东西
You should be able to use analytic functions to generate the running total. Something like
您应该能够使用分析 SQL 函数来完成此操作。
11gR2 http://download.oracle.com/docs/ cd/E14072_01/server.112/e10810/analysis.htm
您应该能够从
“Time_Available”
(您有可能返回负值,用零替换这些值也可以在 SQL 中处理)顺便说一句,我忍不住喜欢您为结果选择的标题。 ..
“扩孔日”
根据项目的不同,A 先生可能会认为栏目标题是适当且合理的。
You should be able to do this with analytic SQL functions.
11gR2 http://download.oracle.com/docs/cd/E14072_01/server.112/e10810/analysis.htm
You should be able to subtract that from
"Time_Available"
(you'll have a potential for returning negative values, replacing those with zeros can be handled in SQL as well)BTW, I can't help but like your chosen title for the result...
"reaming days"
Depending on the project, Mr. A might feel that column title is appropriate and justified.