从MAX(SUM())SQL GROUP BY获取ID
我试图从下图中得到的结果中获取PlayerID 我用来显示的查询是:从MAX(SUM())SQL GROUP BY获取ID,sql,oracle,Sql,Oracle,我试图从下图中得到的结果中获取PlayerID 我用来显示的查询是: SELECT PlayerIDFK, sum(TwoPointMade) as TwoPointMade, sum(ThreePointMade) as ThreePointMAde FROM PlayerPerformance GROUP BY PlayerIDFK; 我还有另一个查询,在本例中返回两列总和的最大值47,这是正确的答案,但我还想得到PlayerIDFK SELECT MAX(SUM(TwoPointMa
SELECT PlayerIDFK, sum(TwoPointMade) as TwoPointMade, sum(ThreePointMade) as ThreePointMAde
FROM PlayerPerformance GROUP BY PlayerIDFK;
我还有另一个查询,在本例中返回两列总和的最大值47,这是正确的答案,但我还想得到PlayerIDFK
SELECT MAX(SUM(TwoPointMade) + SUM(ThreePointMade)) AS "Points"
FROM PlayerPerformance GROUP BY PlayerIDFK;
当我尝试使用查询获取播放器ID时,我没有得到一个组函数。这是我尝试使用的查询:
SELECT PlayerIDFK, MAX(SUM(TwoPointMade) + SUM(ThreePointMade)) AS "Points"
FROM PlayerPerformance GROUP BY PlayerIDFK;
使用
orderby
和rownum
(或仅获取12c+中的前1行
:
请仅使用与您使用的技术相匹配的标签。是,还是?这不是
分组依据的作业<代码>分组依据
不从表中返回行。它生成新行。第5行错误:ORA-00935:组函数嵌套太深请尝试按顺序删除sum()包装。
SELECT *
FROM (SELECT PlayerIDFK, sum(TwoPointMade) as TwoPointMade, sum(ThreePointMade) as ThreePointMAde
FROM PlayerPerformance
GROUP BY PlayerIDFK
ORDER BY ( sum(TwoPointMade) + sum(ThreePointMade) ) desc
) pp
WHERE rownum = 1;