问题描述
我正在尝试使用类似于以下的查询将列转换为行...
我期待 SomeDate 为结果行反映 SYSDATE...但这是我得到的结果:
为什么 SOMEDATE 比 SYSDATE 早 4 年?
正如 Mark 在他的回答中提到的,这至少是 Oracle 11.2.0.1 和 11.2.0.2 版本中的一个错误.
但是根据 this 文章 如果您坚持使用上述 Oracle 版本,则有一个解决方法,即将日期转换为 varchar 格式,然后将其转换回日期数据类型.>
所以查询现在应该是:
I am trying to transpose columns to rows using query similar to the following...
I was expecting SomeDate to reflect SYSDATE for the resulting rows... But this is the result I am getting:
Why is the SOMEDATE 4 years earlier than SYSDATE?
As Mark mentioned in his answer, this is a bug in Oracle 11.2.0.1 and 11.2.0.2 versions atleast.
However as per this article there is a workaround if you are stuck with the Oracle versions mentioned above, which is to convert the date to varchar format and then convert it back to date datatype.
So the query should now be:
这篇关于Oracle UNPIVOT 和 SYSDATE 给出奇怪的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!