Home > Database > Mysql Tutorial > 知方可补不足~row_number,rank,dense_rank,ntile排名函数的用法

知方可补不足~row_number,rank,dense_rank,ntile排名函数的用法

WBOY
Release: 2016-06-07 17:38:54
Original
1261 people have browsed it

这篇文章介绍SQL中4个很有意思的函数,我称它的行标函数,它们是row_number,rank,dense_rank和ntile,下面分别进行介绍。 一 row_number:它为数据表加一个叫行标示的列,它在数据表中是连续的,我们必须按着某个顺序把表排序之后,才能使用row_number,看下

这篇文章介绍SQL中4个很有意思的函数,我称它的行标函数,它们是row_number,rank,dense_rank和ntile,下面分别进行介绍。

一  row_number:它为数据表加一个叫“行标示”的列,它在数据表中是连续的,我们必须按着某个顺序把表排序之后,才能使用row_number,看下列例子:

SELECT row_number() OVER ( ORDER BY SalePrice ) AS row , * FROM Product ,

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template