玖叶教程网

前端编程开发入门

oracle,hive的first_value和last_value函数

--oracle,hive的first_value和last_value函数

--内部分组后取第一条和最后一条(不是记录默认顺序的最后一条,而是排序后的最后一条)

--last列等同于last1列

--最后结果默认会以prdu_num的asc排序

查询:

select  
	first_value(cust_actnum) over (partition by prdu_num order by cust_actnum rows between unbounded preceding and unbounded following) first
	,first_value(cust_actnum) over (partition by prdu_num) first1
	,last_value(cust_actnum) over (partition by prdu_num order by cust_actnum rows between unbounded preceding and unbounded following) last
	--,last_value(cust_actnum) over (partition by prdu_num order by cust_actnum) last22
	,last_value(cust_actnum) over (partition by prdu_num) last1	
	,a.*
from upsrdp.TABLE_DUZHAOZHAO a


结果:

2021-12-23

发表评论:

控制面板
您好,欢迎到访网站!
  查看权限
网站分类
最新留言