,ROW_NUMBER() over用法总结
Posted liling1994
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了,ROW_NUMBER() over用法总结相关的知识,希望对你有一定的参考价值。
select *,ROW_NUMBER() over(partition by paadmrowid order by OperateDate) as group_idx from His_AdmFirstPage where OperateDate between ‘2017-01-01‘ and ‘2017-01-31‘
按照paadmrowid字段进行分区,然后按照OperateDate进行排序
select s.* from (select *,ROW_NUMBER() over(partition by paadmrowid order by OperateDate) as group_idx from His_AdmFirstPage where OperateDate between ‘2017-01-01‘ and ‘2017-01-31‘) s
where s.group_idx=1
以上是关于,ROW_NUMBER() over用法总结的主要内容,如果未能解决你的问题,请参考以下文章
MySQL - ROW_NUMBER() OVER()函数用法详解(分组排序)