問題描述
我正在嘗試使用類似于以下的查詢將列轉換為行...
我期待 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 給出奇怪的結果的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!