首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >根据本星期逾期未交的系统,该日期是如何逾期的?

根据本星期逾期未交的系统,该日期是如何逾期的?
EN

Stack Overflow用户
提问于 2017-05-07 16:36:14
回答 1查看 36关注 0票数 0

我需要满足以下要求

代码语言:javascript
复制
•   Overdue 
o   This Week (Count)
o   Past 3 Weeks (Count)
o   Beyond 3 Weeks (Count)
•   Due
o   This Week (Count)
o   Within 3 Weeks (Count)
o   Beyond 3 Weeks (Count)

我已经尝试了以下查询

代码语言:javascript
复制
select to_date('05-MAY-17') > sysdate-6 and
to_date('05-MAY-17') < sysdate-6 then 'Y'
else 'N' from dual;

这是我硬编码的一周..。我不确定这是不是对的?请给我建议更好的方法来满足我的要求。

提前谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-05-07 17:00:35

想必您应该在类似库应用程序的东西中查询表。所以,您需要的是这样一堆条件计数:

代码语言:javascript
复制
select 
   count( case when due_date < sysdate
                and due_date > sysdate-7 then 1 end ) overdue_one_week
   , count( case when due_date <= sysdate-7 
                  and due_date > sysdate-21 then 1 end ) overdue_three_week
   , count( case when due_date <= sysdate-21 then 1 end ) overdue_longer
   , count( case when due_date >= sysdate 
                  and due_date < sysdate+7 then 1 end ) due_this_week
   , count( case when due_date >= sysdate+7 
                  and due_date < sysdate+21 then 1 end ) due_three_weeks
   , count( case when due_date >= sysdate+21 then 1 end ) due_beyond_three_weeks
from library_loans
/
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43833963

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档