My classmates asked me how to sort the scores of multiple subjects in a table and write the results back to the database. the SQL statements are too simple and too stupid to be written. so I searched everywhere and found the SQL sentences that were updated at the same time in the order of single form subjects. click here if you want to view the original text.
So I made a small modification to the SQL statement to achieve my goal. In my test, the table name is ctest, and the field name is pinyin.
This is before sorting:
The SQL statement used is as follows:
Update ctest
Set mingci = (
Select count (*) + 1
From ctest
Where ctest. fenshu> A. fenshu
And ctest. Kemu = A. Kemu)
From ctest
Among them, and ctest. Kemu = A. Kemu is added to me. In this way, you can rank multiple subjects. If not, you can only think of it as a single subject.
The result is as follows:
The ranking of the same score is the same, and the subsequent ranking will be postponed. For example, there are already two ranking first, and the following is the ranking third, not the second.
I find myself too stupid, so I cannot be so lazy in the future. I should learn more about this.