Syntax: Example: Analysis: Can also be used like this:
Create a test table and insert test data CREATE TABLE TEST_ROW_NUMBER_01( CMZH varchar(10) not null, CYLH varchar(10) null, MJE money null, ); INSERT INTO TEST_ROW_NUMBER_01(CMZH,CYLH,MJE) VALUES (2106000011,20281997,10.50) INSERT INTO TEST_ROW_NUMBER_01(CMZH,CYLH,MJE) VALUES(2106000010,20281996,10.50) INSERT INTO TEST_ROW_NUMBER_01(CMZH,CYLH,MJE) VALUES(2106000008,20281995,0.00) INSERT INTO TEST_ROW_NUMBER_01(CMZH,CYLH,MJE) VALUES(2106000006,20281994,9.50) INSERT INTO TEST_ROW_NUMBER_01(CMZH,CYLH,MJE) VALUES(2106000004,20281993,5.50) INSERT INTO TEST_ROW_NUMBER_01(CMZH,CYLH,MJE) VALUES(2106000001,20281992,10.50) INSERT INTO TEST_ROW_NUMBER_01(CMZH,CYLH,MJE) VALUES(2106000002,20281992,10.50) INSERT INTO TEST_ROW_NUMBER_01(CMZH,CYLH,MJE) VALUES(2106000007,20217280,0.00) INSERT INTO TEST_ROW_NUMBER_01(CMZH,CYLH,MJE) VALUES(2106000009,20172458,5.50) INSERT INTO TEST_ROW_NUMBER_01(CMZH,CYLH,MJE) VALUES(2106000005,20121813,0.00) Execute the script to automatically generate line numbers and sort by CYLH (swipe to view the code) SELECT ROW_NUMBER() OVER(ORDER BY CYLH DESC) AS ROWNUM,* FROM TEST_ROW_NUMBER_01 The results are as follows: Note: When using window functions such as This is the end of this article about using SQL ROW_NUMBER() OVER function to generate serial numbers. For more information about using SQL ROW_NUMBER() OVER to generate serial numbers, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: What are the attributes of the JSscript tag
>>: Introduction and use of five controllers in K8S
For novices who have just started to build a webs...
I haven't worked with servers for a while. No...
Table of contents Overview 1. useState 1.1 Three ...
When using Navicat to connect to a remote Linux M...
This article example shares the specific code of ...
ENV: [root@centos7 ~]# uname -r 3.10.0-514.el7.x8...
Most people compile MySQL and put it in the syste...
question: When developing the Alice management sy...
This article example shares the specific code of ...
1. When the width of the adjacent floating layer o...
Table of contents Setting up a basic HTTP request...
illustrate: Using mysqldump –all-databases will e...
Table of contents Preface 1. unknown vs any 2. Th...
If you cannot download it by clicking downloadlao...
Ubuntu 18.04, other versions of Ubuntu question: ...