首页 > 其他分享 >分区函数Partition by使用

分区函数Partition by使用

时间:2022-11-30 14:12:51浏览次数:32  
标签:partition group 函数 over Partition order 分组 分区

1、PARTITION BY使用

基本语法 over(partition by col1 order by col2);

select t.*,row_number() over( order by data_date desc) rowIndex from table t;

2、over partition by与group by的区别:

group by是对检索结果的保留行进行单纯分组,一般和聚合函数一起使用例如max、min、sum、avg、count等一块用。

partition by 对于每个每个分组返回多行,虽然也具有分组功能,但同时也具有其他的高级功能。

标签:partition,group,函数,over,Partition,order,分组,分区
From: https://www.cnblogs.com/PickJackTT/p/16938228.html

相关文章