Questions tagged «mysql-variables»

10
获取每组分组结果的前n条记录
以下是最简单的示例,尽管任何解决方案都应能够扩展到需要许多n个顶级结果的地方: 给定下面的表格,其中包含“人员”,“组”和“年龄”列,您将如何获得每个组中年龄最大的2个人?(组内的关系不应产生更多结果,而应按字母顺序给出前2个) + -------- + ------- + ----- + | 人 集团| 年龄| + -------- + ------- + ----- + | 鲍勃| 1 | 32 | | 吉尔| 1 | 34 | | 肖恩| 1 | 42 | | 杰克 2 | 29 | | 保罗| 2 | 36 | …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.