使用有效的日期记录
如何获取员工,例如有效日期记录中的 5 个最新 Action_reason 行,没有未来行,应仅选择当前行和历史行(有效日期 <= sysdate)。 我可以在单行中获取这些数据,还是对于 Employee 来说它是 5 行?
select emplid, effdt, action_reasons
-- we have to build a logic here.
-- Should we initialize 5 ACT variables to fetch rows into it?
-- Please help
from JOB
where emplid = '12345'
and effdt <= sysdate.
How to fetch an Employees, say 5 latest Action_reason rows which are in an effective dated record, no future rows, should select only current and history rows(effective date <= sysdate). Can I fetch these in single row or will it be 5 rows for an Employee?
select emplid, effdt, action_reasons
-- we have to build a logic here.
-- Should we initialize 5 ACT variables to fetch rows into it?
-- Please help
from JOB
where emplid = '12345'
and effdt <= sysdate.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以按照您希望的方式获取数据。 如果您希望它为五行,那么您可以使用以下内容:
如果您希望所有数据都在一行上,则使用 Oracle 的 LAG 分析函数,因此:
这给出了最后 5 个 effdt 值和最后 5 个操作原因值。 如果您不需要上述两者,则可以相应地修剪上述 SQL。
You can have the data any way you wish. If you want it as five rows then you could use this:
If you want the data all on a single line then use Oracle's LAG analytic function, thus:
This gives the last 5 effdt values and the last 5 action reason values. If you don't need both the above SQL can be trimmed accordingly.