MySQL group sorting to find the top N Table Structure Group by grp, sort by num, and take the top 3 in each group. The output is as follows: source code: SELECT * FROM score AS t3 WHERE ( SELECT COUNT(*) FROM score AS t1 LEFT JOIN score AS t2 ON t1.grp = t2.grp AND t1.num < t2.num WHERE t1.id = t3.id ) < 3 ORDER BY t3.grp ASC, num DESC In where, you can create a new variable for filtering through a subquery. Thank you for reading, I hope it can help you, thank you for your support of this site! You may also be interested in:
|
<<: React+Koa example of implementing file upload
>>: How to build Jenkins+Maven+Git continuous integration environment on CentOS7
MySQL replication table detailed explanation If w...
I don’t know if you have ever encountered such a ...
Core code /*-------------------------------- Find...
Collapsed headers are a great solution for displa...
1. Download, I take 8.0 as an example Download ad...
Proxying multiple 302s with proxy_intercept_error...
Click here to return to the 123WORDPRESS.COM HTML ...
Table of contents TypeScript environment construc...
This article will not explain the use and install...
Table of contents 1. Maven Dependency 2. Menu rel...
Table of contents Preface interface type Appendix...
Copy code The code is as follows: <meta name=&...
Preface This article is just a simple record of m...
Aggregating data from various sources allows the ...
introduction: Slider drag verification is now use...