第八章_函数【窗口函数】

1. 开窗函数的作用
说明 : 开窗函数就是 根据指定的开窗规则 为表的每条记录,标记状态,不会增加或者减少表的记录数
2. 语法
分析函数、聚合函数 over(partition by 列名 order by 列名 rows between 开始位置 and 结束位置)
注意 : over(partition by x order by y) = over(distribute by x sort by y)
3. 分区 : partition by 列名
说明 : 按照指定字段分区,可以为多个字段,相当于 group by
不指定分区时,操作的是全表

4. 排序 : order by 列名 [asc|desc]
说明 : 按照指定字段,进行排序(默认为asc)
如果指定分区,则是分区内排序,不指定分区,则是全表排序
      聚合函数 + 开窗范围 + order by = 累计求值
5. 开窗范围(window specification) : rows between 开始位置 and 结束位置
    说明 : 计算的范围
注意 : 1. 不指定时,默认范围: 第一行到当前行
      2. 开窗范围 语法能在 聚合函数(
count、sum、min、max、avg)中使用
    位置参数 : 
current row:当前行
n preceding:往前 n 行数据
n following:往后 n 行数据
unbounded:起点,
unbounded preceding 表示该窗口最前面的行(起点)
unbounded following 表示该窗口最后面的行(终点)

示例 :
        rows between unbounded preceding and current row -- 表示从起点到当前行
        rows between 2 preceding and 1 following -- 表示往前2行到往后1行
        rows between 2 preceding and current row -- 表示往前2行到当前行
        rows between current row and unbounded following -- 表示当前行到终点
        rows between unbounded preceding and 1 preceding -- 首行到当前行的前一行
rows between unbounded preceding and unbounded following -- 首行到终点

复制代码
with t1 as (
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-03' as credit_date,12 as score
union all
select 'huawei' as channel ,'2021-08-04' as credit_date,25 as score
union all
select 'huawei' as channel ,'2021-08-02' as credit_date,1 as score
union all
select 'huawei' as channel ,'2021-08-07' as credit_date,7 as score
union all
select 'huawei' as channel ,'2021-08-08' as credit_date,10 as score
union all
select 'huawei' as channel ,'2021-08-06' as credit_date,33 as score
union all
select 'vivo' as channel ,'2021-09-01' as credit_date,1 as score
union all
select 'vivo' as channel ,'2021-09-02' as credit_date,2 as score
union all
select 'vivo' as channel ,'2021-09-04' as credit_date,5 as score
union all
select 'vivo' as channel ,'2021-09-09' as credit_date,9 as score
union all
select 'vivo' as channel ,'2021-09-07' as credit_date,77 as score
union all
select 'vivo' as channel ,'2021-09-08' as credit_date,10 as score
union all
select 'vivo' as channel ,'2021-09-11' as credit_date,3 as score
)
select *
,sum(t1.score) over(partition by t1.channel
    ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
    ) as sum1 -- 开窗范围:首行~当前行(默认参数为此参数)
,sum(t1.score) over(partition by t1.channel
    ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING
    ) as sum2 -- 开窗范围:当前行~末尾行
from t1
;
channel credit_date   score     sum1    sum2
huawei  2021-08-01      5       5       98
huawei  2021-08-06      33      38      93
huawei  2021-08-08      10      48      60
huawei  2021-08-07      7       55      50
huawei  2021-08-02      1       56      43
huawei  2021-08-04      25      81      42
huawei  2021-08-03      12      93      17
huawei  2021-08-01      5       98      5
vivo    2021-09-08      10      10      107
vivo    2021-09-07      77      87      97
vivo    2021-09-09      9       96      20
vivo    2021-09-04      5       101     11
vivo    2021-09-02      2       103     6
vivo    2021-09-01      1       104     4
vivo    2021-09-11      3       107     3
View Code
复制代码

6. 聚合函数
count、sum、min、max、avg
7. 分析函数
rank : 跳跃排序 当排序字段值相同时, 自增序号重复,且会跳过下一个序号 示例(1,2,3,4,4,6)
row_number : 连续排序 当排序字段值相同时, 自增序号不会重复 示例(1,2,3,4,5,6)
dense_rank : 密集排序 当排序字段值相同时, 自增序号重复,且不会跳过下一个序号 示例(1,2,3,4,4,5)
cume_dist : <= 当前值的记录数据 / 分组内总记录数
percent_rank : 分组内当前行的RANK值-1/分组内总行数-1
ntile(x) : 将窗口内数据进行切片(根据序号),并返回该记录的切片编号
当切片不均时,默认增加第一个切片的分布
         
说明 :根据row_number,将数据划分为x等份,x为ntile(x)

-- 7.1 排序函数示例
-- rank、dense_rank、row_number
复制代码
-- 排序函数示例
-- rank、dense_rank、row_number
with t1 as (
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-03' as credit_date,12 as score
union all
select 'huawei' as channel ,'2021-08-04' as credit_date,25 as score
union all
select 'huawei' as channel ,'2021-08-02' as credit_date,1 as score
union all
select 'huawei' as channel ,'2021-08-07' as credit_date,7 as score
union all
select 'huawei' as channel ,'2021-08-08' as credit_date,10 as score
union all
select 'huawei' as channel ,'2021-08-06' as credit_date,33 as score
union all
select 'vivo' as channel ,'2021-09-01' as credit_date,1 as score
union all
select 'vivo' as channel ,'2021-09-02' as credit_date,2 as score
union all
select 'vivo' as channel ,'2021-09-04' as credit_date,5 as score
union all
select 'vivo' as channel ,'2021-09-09' as credit_date,9 as score
union all
select 'vivo' as channel ,'2021-09-07' as credit_date,77 as score
union all
select 'vivo' as channel ,'2021-09-08' as credit_date,10 as score
union all
select 'vivo' as channel ,'2021-09-11' as credit_date,3 as score
)
select *
,rank() over(partition by t1.channel order by t1.score) as rank
,dense_rank() over(partition by t1.channel order by t1.score) as dense_rank
,row_number() over(partition by t1.channel order by t1.score) as row_number

from t1;
channel credit_date   score    rank dense_rank      row_number
huawei  2021-08-02      1       1       1           1
huawei  2021-08-01      5       2       2           2
huawei  2021-08-01      5       2       2           3
huawei  2021-08-07      7       4       3           4
huawei  2021-08-08      10      5       4           5
huawei  2021-08-03      12      6       5           6
huawei  2021-08-04      25      7       6           7
huawei  2021-08-06      33      8       7           8
vivo    2021-09-01      1       1       1           1
vivo    2021-09-02      2       2       2           2
vivo    2021-09-11      3       3       3           3
vivo    2021-09-04      5       4       4           4
vivo    2021-09-09      9       5       5           5
vivo    2021-09-08      10      6       6           6
vivo    2021-09-07      77      7       7           7
View Code
复制代码

-- 7.2 统计当前记录组内占比
-- cume_dist
复制代码
-- 7.2 统计当前记录组内占比
-- cume_dist
with t1 as (
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-03' as credit_date,12 as score
union all
select 'huawei' as channel ,'2021-08-04' as credit_date,25 as score
union all
select 'huawei' as channel ,'2021-08-02' as credit_date,1 as score
union all
select 'huawei' as channel ,'2021-08-07' as credit_date,7 as score
union all
select 'huawei' as channel ,'2021-08-08' as credit_date,10 as score
union all
select 'huawei' as channel ,'2021-08-06' as credit_date,33 as score
union all
select 'vivo' as channel ,'2021-09-01' as credit_date,1 as score
union all
select 'vivo' as channel ,'2021-09-02' as credit_date,2 as score
union all
select 'vivo' as channel ,'2021-09-04' as credit_date,5 as score
union all
select 'vivo' as channel ,'2021-09-09' as credit_date,9 as score
union all
select 'vivo' as channel ,'2021-09-07' as credit_date,77 as score
union all
select 'vivo' as channel ,'2021-09-08' as credit_date,10 as score
union all
select 'vivo' as channel ,'2021-09-11' as credit_date,3 as score
)
select *
,cume_dist() over(partition by t1.channel order by t1.score) as zhanbi
from t1;
channel credit_date  score    zhanbi
huawei  2021-08-02      1       0.125
huawei  2021-08-01      5       0.375
huawei  2021-08-01      5       0.375
huawei  2021-08-07      7       0.5
huawei  2021-08-08      10      0.625
huawei  2021-08-03      12      0.75
huawei  2021-08-04      25      0.875
huawei  2021-08-06      33      1.0
vivo    2021-09-01      1       0.14285714285714285
vivo    2021-09-02      2       0.2857142857142857
vivo    2021-09-11      3       0.42857142857142855
vivo    2021-09-04      5       0.5714285714285714
vivo    2021-09-09      9       0.7142857142857143
vivo    2021-09-08      10      0.8571428571428571
vivo    2021-09-07      77      1.0
View Code
复制代码

-- 7.3 统计当前排序号组内占比
-- percent_rank
复制代码
-- 7.3 统计当前排序号组内占比
-- percent_rank
with t1 as (
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-03' as credit_date,12 as score
union all
select 'huawei' as channel ,'2021-08-04' as credit_date,25 as score
union all
select 'huawei' as channel ,'2021-08-02' as credit_date,1 as score
union all
select 'huawei' as channel ,'2021-08-07' as credit_date,7 as score
union all
select 'huawei' as channel ,'2021-08-08' as credit_date,10 as score
union all
select 'huawei' as channel ,'2021-08-06' as credit_date,33 as score
union all
select 'vivo' as channel ,'2021-09-01' as credit_date,1 as score
union all
select 'vivo' as channel ,'2021-09-02' as credit_date,2 as score
union all
select 'vivo' as channel ,'2021-09-04' as credit_date,5 as score
union all
select 'vivo' as channel ,'2021-09-09' as credit_date,9 as score
union all
select 'vivo' as channel ,'2021-09-07' as credit_date,77 as score
union all
select 'vivo' as channel ,'2021-09-08' as credit_date,10 as score
union all
select 'vivo' as channel ,'2021-09-11' as credit_date,3 as score
)
select *
,percent_rank() over(partition by t1.channel order by t1.score) as rank_zhanbi
,rank() over(partition by t1.channel order by t1.score) as rank
from t1;
channel credit_date   score     rank_zhanbi           rank
huawei  2021-08-02      1       0.0                     1
huawei  2021-08-01      5       0.14285714285714285     2
huawei  2021-08-01      5       0.14285714285714285     2
huawei  2021-08-07      7       0.42857142857142855     4
huawei  2021-08-08      10      0.5714285714285714      5
huawei  2021-08-03      12      0.7142857142857143      6
huawei  2021-08-04      25      0.8571428571428571      7
huawei  2021-08-06      33      1.0                     8
vivo    2021-09-01      1       0.0                     1
vivo    2021-09-02      2       0.16666666666666666     2
vivo    2021-09-11      3       0.3333333333333333      3
vivo    2021-09-04      5       0.5                     4
vivo    2021-09-09      9       0.6666666666666666      5
vivo    2021-09-08      10      0.8333333333333334      6
vivo    2021-09-07      77      1.0                     7
View Code
复制代码

-- 7.4 切片函数
-- ntile
复制代码
-- 7.4 切片函数
-- ntile
with t1 as (
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-03' as credit_date,12 as score
union all
select 'huawei' as channel ,'2021-08-04' as credit_date,25 as score
union all
select 'huawei' as channel ,'2021-08-02' as credit_date,1 as score
union all
select 'huawei' as channel ,'2021-08-07' as credit_date,7 as score
union all
select 'huawei' as channel ,'2021-08-08' as credit_date,10 as score
union all
select 'huawei' as channel ,'2021-08-06' as credit_date,33 as score
union all
select 'vivo' as channel ,'2021-09-01' as credit_date,1 as score
union all
select 'vivo' as channel ,'2021-09-02' as credit_date,2 as score
union all
select 'vivo' as channel ,'2021-09-04' as credit_date,5 as score
union all
select 'vivo' as channel ,'2021-09-09' as credit_date,9 as score
union all
select 'vivo' as channel ,'2021-09-07' as credit_date,77 as score
union all
select 'vivo' as channel ,'2021-09-08' as credit_date,10 as score
union all
select 'vivo' as channel ,'2021-09-11' as credit_date,3 as score
)
select *
,ntile(2) over(partition by t1.channel order by t1.score) as splitNum
from t1;
channel credit_date  score    splitnum
huawei  2021-08-02      1       1
huawei  2021-08-01      5       1
huawei  2021-08-01      5       1
huawei  2021-08-07      7       1
huawei  2021-08-08      10      2
huawei  2021-08-03      12      2
huawei  2021-08-04      25      2
huawei  2021-08-06      33      2
vivo    2021-09-01      1       1
vivo    2021-09-02      2       1
vivo    2021-09-11      3       1
vivo    2021-09-04      5       1
vivo    2021-09-09      9       2
vivo    2021-09-08      10      2
vivo    2021-09-07      77      2
View Code
复制代码

 

8. 窗口函数(lag,lead,first_value,last_value)

lag :
说明 : 用来访问前一行的数据(UDF)
语法 : LAG (scalar_expression [,offset] [,default]) OVER ([query_partition_clause] order_by_clause);
scalar_expression : 指定字段名称
offset : 当前行的前x行,默认为1
default : 指定 字段为空时的 默认值,默认值 为null

lead :
说明 : 用来访问后一行的数据(UDF)
语法 : LEAD (scalar_expression [,offset] [,default]) OVER ([query_partition_clause] order_by_clause);
scalar_expression : 指定字段名称
offset : 当前行的后x行,默认为1
default : 指定 字段为空时的 默认值,默认值 为null

first_value :
说明 : 获取 分组内排序第一的数据(第一行到当前行)

last_value :
说明 : 获取 分组内排序最后的数据(第一行到当前行)
-- 1. lag 示例
复制代码
-- 1. lag
with t1 as (
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-03' as credit_date,12 as score
union all
select 'huawei' as channel ,'2021-08-04' as credit_date,25 as score
union all
select 'huawei' as channel ,'2021-08-02' as credit_date,1 as score
union all
select 'huawei' as channel ,'2021-08-07' as credit_date,7 as score
union all
select 'huawei' as channel ,'2021-08-08' as credit_date,10 as score
union all
select 'huawei' as channel ,'2021-08-06' as credit_date,33 as score
union all
select 'vivo' as channel ,'2021-09-01' as credit_date,1 as score
union all
select 'vivo' as channel ,'2021-09-02' as credit_date,2 as score
union all
select 'vivo' as channel ,'2021-09-04' as credit_date,5 as score
union all
select 'vivo' as channel ,'2021-09-09' as credit_date,9 as score
union all
select 'vivo' as channel ,'2021-09-07' as credit_date,77 as score
union all
select 'vivo' as channel ,'2021-09-08' as credit_date,10 as score
union all
select 'vivo' as channel ,'2021-09-11' as credit_date,3 as score
)
select *
,lag(credit_date) over(partition by t1.channel order by t1.score) as pre1_row -- 当前行的前一行
,lag(credit_date,2,'9999-99-99') over(partition by t1.channel order by t1.score) as pre2_row -- 当前行的前2行,为null时默认值为 9999-99-99
from t1;

channel credit_date   score     pre1_row        pre2_row
huawei  2021-08-02      1       NULL            9999-99-99
huawei  2021-08-01      5       2021-08-02      9999-99-99
huawei  2021-08-01      5       2021-08-01      2021-08-02
huawei  2021-08-07      7       2021-08-01      2021-08-01
huawei  2021-08-08      10      2021-08-07      2021-08-01
huawei  2021-08-03      12      2021-08-08      2021-08-07
huawei  2021-08-04      25      2021-08-03      2021-08-08
huawei  2021-08-06      33      2021-08-04      2021-08-03
vivo    2021-09-01      1       NULL            9999-99-99
vivo    2021-09-02      2       2021-09-01      9999-99-99
vivo    2021-09-11      3       2021-09-02      2021-09-01
vivo    2021-09-04      5       2021-09-11      2021-09-02
vivo    2021-09-09      9       2021-09-04      2021-09-11
vivo    2021-09-08      10      2021-09-09      2021-09-04
vivo    2021-09-07      77      2021-09-08      2021-09-09
View Code
复制代码

-- 2. lead 示例
复制代码
-- 2. lead 示例
with t1 as (
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-03' as credit_date,12 as score
union all
select 'huawei' as channel ,'2021-08-04' as credit_date,25 as score
union all
select 'huawei' as channel ,'2021-08-02' as credit_date,1 as score
union all
select 'huawei' as channel ,'2021-08-07' as credit_date,7 as score
union all
select 'huawei' as channel ,'2021-08-08' as credit_date,10 as score
union all
select 'huawei' as channel ,'2021-08-06' as credit_date,33 as score
union all
select 'vivo' as channel ,'2021-09-01' as credit_date,1 as score
union all
select 'vivo' as channel ,'2021-09-02' as credit_date,2 as score
union all
select 'vivo' as channel ,'2021-09-04' as credit_date,5 as score
union all
select 'vivo' as channel ,'2021-09-09' as credit_date,9 as score
union all
select 'vivo' as channel ,'2021-09-07' as credit_date,77 as score
union all
select 'vivo' as channel ,'2021-09-08' as credit_date,10 as score
union all
select 'vivo' as channel ,'2021-09-11' as credit_date,3 as score
)
select *
,lead(credit_date) over(partition by t1.channel order by t1.score) as next1_row -- 当前行的前一行
,lead(credit_date,2,'9999-99-99') over(partition by t1.channel order by t1.score) as next2_row -- 当前行的前2行,为null时默认值为 9999-99-99
from t1;
channel credit_date  score      next1_row       next2_row
huawei  2021-08-02      1       2021-08-01      2021-08-01
huawei  2021-08-01      5       2021-08-01      2021-08-07
huawei  2021-08-01      5       2021-08-07      2021-08-08
huawei  2021-08-07      7       2021-08-08      2021-08-03
huawei  2021-08-08      10      2021-08-03      2021-08-04
huawei  2021-08-03      12      2021-08-04      2021-08-06
huawei  2021-08-04      25      2021-08-06      9999-99-99
huawei  2021-08-06      33      NULL            9999-99-99
vivo    2021-09-01      1       2021-09-02      2021-09-11
vivo    2021-09-02      2       2021-09-11      2021-09-04
vivo    2021-09-11      3       2021-09-04      2021-09-09
vivo    2021-09-04      5       2021-09-09      2021-09-08
vivo    2021-09-09      9       2021-09-08      2021-09-07
vivo    2021-09-08      10      2021-09-07      9999-99-99
vivo    2021-09-07      77      NULL            9999-99-99
View Code
复制代码

-- 3. first_value、last_value 示例
复制代码
-- 3. first_value、last_value 示例
with t1 as (
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-03' as credit_date,12 as score
union all
select 'huawei' as channel ,'2021-08-04' as credit_date,25 as score
union all
select 'huawei' as channel ,'2021-08-02' as credit_date,1 as score
union all
select 'huawei' as channel ,'2021-08-07' as credit_date,7 as score
union all
select 'huawei' as channel ,'2021-08-08' as credit_date,10 as score
union all
select 'huawei' as channel ,'2021-08-06' as credit_date,33 as score
union all
select 'vivo' as channel ,'2021-09-01' as credit_date,1 as score
union all
select 'vivo' as channel ,'2021-09-02' as credit_date,2 as score
union all
select 'vivo' as channel ,'2021-09-04' as credit_date,5 as score
union all
select 'vivo' as channel ,'2021-09-09' as credit_date,9 as score
union all
select 'vivo' as channel ,'2021-09-07' as credit_date,77 as score
union all
select 'vivo' as channel ,'2021-09-08' as credit_date,10 as score
union all
select 'vivo' as channel ,'2021-09-11' as credit_date,3 as score
)
select *
,first_value(credit_date) over(partition by t1.channel order by t1.score) as first_value
,last_value(credit_date) over(partition by t1.channel order by t1.score) as last_value
,row_number() over(partition by t1.channel order by t1.score) as rank
from t1;
channel credit_date  score      first_value     last_value      rank
huawei  2021-08-02      1       2021-08-02      2021-08-02      1
huawei  2021-08-01      5       2021-08-02      2021-08-01      2
huawei  2021-08-01      5       2021-08-02      2021-08-01      3
huawei  2021-08-07      7       2021-08-02      2021-08-07      4
huawei  2021-08-08      10      2021-08-02      2021-08-08      5
huawei  2021-08-03      12      2021-08-02      2021-08-03      6
huawei  2021-08-04      25      2021-08-02      2021-08-04      7
huawei  2021-08-06      33      2021-08-02      2021-08-06      8
vivo    2021-09-01      1       2021-09-01      2021-09-01      1
vivo    2021-09-02      2       2021-09-01      2021-09-02      2
vivo    2021-09-11      3       2021-09-01      2021-09-11      3
vivo    2021-09-04      5       2021-09-01      2021-09-04      4
vivo    2021-09-09      9       2021-09-01      2021-09-09      5
vivo    2021-09-08      10      2021-09-01      2021-09-08      6
vivo    2021-09-07      77      2021-09-01      2021-09-07      7
View Code
复制代码

9. window clause (窗口子句)
说明: 将窗口部分单独提出来,放入表的后面使用,多个函数 可以共享一个窗口
-- window clause 示例
复制代码
-- window clause 示例
with t1 as (
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-01' as credit_date,5 as score
union all
select 'huawei' as channel ,'2021-08-03' as credit_date,12 as score
union all
select 'huawei' as channel ,'2021-08-04' as credit_date,25 as score
union all
select 'huawei' as channel ,'2021-08-02' as credit_date,1 as score
union all
select 'huawei' as channel ,'2021-08-07' as credit_date,7 as score
union all
select 'huawei' as channel ,'2021-08-08' as credit_date,10 as score
union all
select 'huawei' as channel ,'2021-08-06' as credit_date,33 as score
union all
select 'vivo' as channel ,'2021-09-01' as credit_date,1 as score
union all
select 'vivo' as channel ,'2021-09-02' as credit_date,2 as score
union all
select 'vivo' as channel ,'2021-09-04' as credit_date,5 as score
union all
select 'vivo' as channel ,'2021-09-09' as credit_date,9 as score
union all
select 'vivo' as channel ,'2021-09-07' as credit_date,77 as score
union all
select 'vivo' as channel ,'2021-09-08' as credit_date,10 as score
union all
select 'vivo' as channel ,'2021-09-11' as credit_date,3 as score
)
select *
,count(credit_date) over w1 as cnt
,sum(score) over w1 as sum
from t1
window w1 as (partition by t1.channel order by t1.score)
;

channel credit_date  score     cnt     sum
huawei  2021-08-02      1       1       1
huawei  2021-08-01      5       3       11
huawei  2021-08-01      5       3       11
huawei  2021-08-07      7       4       18
huawei  2021-08-08      10      5       28
huawei  2021-08-03      12      6       40
huawei  2021-08-04      25      7       65
huawei  2021-08-06      33      8       98
vivo    2021-09-01      1       1       1
vivo    2021-09-02      2       2       3
vivo    2021-09-11      3       3       6
vivo    2021-09-04      5       4       11
vivo    2021-09-09      9       5       20
vivo    2021-09-08      10      6       30
vivo    2021-09-07      77      7       107
View Code
复制代码

10. 参考链接
  
官网 : https://cwiki.apache.org/confluence/display/Hive/LanguageManual+WindowingAndAnalytics
案例1 : http://lxw1234.com/archives/tag/hive-window-functions
  案例2 :https://blog.csdn.net/a934079371/article/details/108301730?utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-3.control&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7Edefault-3.control
posted @   学而不思则罔!  阅读(377)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· SpringCloud带你走进微服务的世界
点击右上角即可分享
微信分享提示