How to query ranking function by SQL
This article will explain in detail how to query the ranking function of SQL. The content of the article is of high quality, so the editor will share it with you for reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
In actual development, we often encounter the situation of calculating the ranking of a field.
As in the following table: totak_sales
Now this is required: sort by the reverse order of sales, and add a sales_rank field to display the ranking order
Methods:
The code is as follows: SELECT a1.Name, a1.Sales, COUNT (a2.sales) Sales_RankFROM Total_Sales A1, Total_Sales a2WHERE a1.Sales