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
Preface Before we begin, we should briefly unders...
Copy code The code is as follows: <form method...
MySQL and connection related timeouts Preface: To...
<br />I have been working in front-end for s...
Table of contents 1. Keywords 2. Deconstruction 3...
Table of contents Preface 1. Use for...of to iter...
Table of contents Concurrent scenarios Write-Writ...
1. Copy the configuration file to the user enviro...
1. Add PRIMARY KEY (primary key index) mysql>A...
Two methods to implement Mysql remote connection ...
Table of contents summary Problem Description Ana...
Table of contents fold (reduce) Using for...of Us...
Arial Arial is a sans-serif TrueType font distribu...
Table of contents Preface zx library $`command` c...
Preface An index is a data structure that sorts o...