Get the App
SLTechnology News&Howtos  ›  Database  › 

How to query ranking function by SQL

Shulou Source: shulou.com Published: 2022-05-31 16:54:27 11月16日 Update

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

Tags: Code content function query field article more knowledge article result good actual regular situation scheme method quality reverse order selected faceted Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia macOS Apple OPPO Reno Microsoft