赞
踩
函数的作用恰如其名,取出首尾记录值。
需要注意的是:
first_value()是取第一个值,没有异议。
last_value()默认统计范围是 rows between unbounded preceding and current row,取的是当前行的尾值;如需取当前所有环节的尾值,需要指定:rows between unbounded preceding and unbounded following
SELECT DISTINCT LAST_VALUE(a.COMPLETE_TIME)
OVER (PARTITION BY a.ACTIVITY_INST_NAME
ORDER BY a.CREATE_TIME ROWS BETWEEN unbounded preceding AND unbounded following) AS LAST_TIME_VALUE,
FIRST_VALUE(a.CREATE_TIME)
OVER (PARTITION BY a.ACTIVITY_INST_NAME
ORDER BY a.CREATE_TIME ROWS BETWEEN unbounded preceding AND unbounded following) AS FIRST_TIME_VALUE,
a.ACTIVITY_INST_NAME
FROM V_WS_NEWLOCALCIRCUIT_TASK a
WHERE 1=1
AND A.SHEET_ID = 'ZJF-388-191016-00071'
原始数据与查询结果对比:
有木有解决电脑前你的问题,欢迎点赞和讨论~
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。