Last_value
窗口功能doesn't
正常工作。
CREATE TABLE EXAMP2
(
CUSTOMER_ID NUMBER(38) NOT NULL,
VALID_FROM DATE NOT NULL
);
Customer_id Valid_from
-------------------------------------
9775 06.04.2013 01:34:16
9775 06.04.2013 20:34:00
9775 12.04.2013 11:07:01
--------------------------------------
select DISTINCT LAST_VALUE(VALID_FROM)
OVER (partition by customer_id ORDER BY VALID_FROM ASC) rn
from examp1;
当我使用时LAST_VALUE
,我得到以下行:
06.04.2013 20:34:00
06.04.2013 01:34:16
12.04.2013 11:07:01
当我使用时FIRST_VALUE
,我得到以下行:
select DISTINCT FIRST_VALUE(VALID_FROM)
OVER (partition by customer_id ORDER BY VALID_FROM DESC) rn
from examp1;
4/12/2013 11:07:01 AM
First_value
查询给出正确的输出。我希望从这些查询中获得相同的输出。为什么我有2 different results
?