pgsql row_number()
时间: 2023-10-15 10:31:48 浏览: 105
引用:Postgresql 根据单列或几列分组去重row_number() over() partition by 。 引用:语法 row_number() over( [partition by col1] order by col2[desc]) row_number() 为返回的记录定义各行编号pritition by 分组order by 排序 我们都知道distinct 可以去重,但我今天重点讲使用row_number()函数去重 。
在PgSQL中,row_number()函数是用于为查询结果集中的每一行分配一个唯一的行号。通过使用partition by子句,我们可以在查询结果集中根据单列或多列进行分组。partition by子句将结果集分成不同的分区,然后在每个分区内对数据进行排序。使用order by子句可以指定排序的列和排序的顺序。通过这种方式,我们可以实现基于分组的去重操作。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [Postgresql 根据单列或几列分组去重row_number() over() partition by](https://blog.csdn.net/qq_40985985/article/details/128953716)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [navicat112_pgsql_cs_x64.exe](https://download.csdn.net/download/u012411153/11828912)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [PostgreSQL的row_number() over() 用法](https://blog.csdn.net/Gzigithub/article/details/87803148)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文