oracle - 下周在甲骨文
问题描述
我正在使用 oracle dbms,并且我在Employe
表中有一个列Birthdate
。我想写一个查询来显示下周过生日的员工。它是否正确 ?
select name
from employe
where to_char(birthdate,'DD-MM')=to_char(next_day(sysdate,1)+7,'DD-MM');
解决方案
这不是正确用法next_day()
:该函数返回一天中下一个实例的日期。例如,要查找下周五的日期:
select next_day(sysdate, 'FRIDAY') from dual;
要查找生日在 7 天后的员工,您只需稍微调整一下查询:
select name
from employe
where to_char(birthdate,'DD-MM') = to_char(sysdate+7,'DD-MM');
推荐阅读
- typescript - 打字稿:箭头功能的通用功能类型/接口
- rest - 什么是 API“突发”请求以及如何在 python 中创建它们?
- javascript - 如何使材料 UI 选项卡标签离开?默认情况下它的中心对齐
- elasticsearch - 密集向量数组和余弦相似度
- php - 通过不相等的值过滤多维数组以排除重复的记录
- java - 如何对具有不同整数值的数组进行排序
- hive - 如何使用查询表分区列表
- azure-devops - Azure 代理配置设置错误 WinHttp 错误:ERROR_WINHTTP_TIMEOUT
- shell - 如何从管道访问环境变量并将其传递给发布管道
- python - 未找到 Pyscopg2 模块