获取前 20 个 mysql 查询错误 [英] Getting Top 20 mysql Query Error

查看:38
本文介绍了获取前 20 个 mysql 查询错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图获得:获得奖励总额最高的前 20 名 PI 及其所属大学.

Trying to get: The top-20 PIs who have the largest total amount of awards along with the universities they are affliated with.

Mysql: SELECT Award, pi, org FROM tbl WHERE groupby(award) LIMIT 20

表格:

它似乎不喜欢我的 group by.这里出了什么问题?

It seems to not like my group by. Whats going wrong here?

推荐答案

With

SELECT award, pi, org FROM tbl WHERE groupby(award) LIMIT 20

你会得到 SQL 错误 (1305): FUNCTION xxx.groupby 不存在

您需要以下代替,假设 pi 单独是唯一的,并且 org 在同一个表中(非规范化)

You need the below instead, assuming pi alone is unique, and org is in the same table (denormalised)

SELECT pi, org, count(award) awardcount
FROM tbl
GROUP BY pi, org
ORDER BY awardcount DESC
LIMIT 20;

这篇关于获取前 20 个 mysql 查询错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆