我需要的是从日期到半年的转换:
- 2018年6月29日 -> 1
- 2018年5月1日 -> 1
- 2018年7月1日 -> 2
- 2018年10月15日 -> 2
我在这里没有找到类似的东西Round and Truncate in Oracle
那么,确实不存在内置函数吗?我很困惑,因为这并不是一个非常罕见的用例。或者我错过了什么?
最佳答案
只需使用 case
表达式:
select (case when extract(month from datecol) <= 6 then 1
else 2
end) as half_year
关于sql - Oracle:日期至半年,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51101916/