开发者

why this query is faling?

select max( sum(duration) ),cd from rent group by cd;开发者_运维问答 

.

ERROR 1111 (HY000): Invalid use of group function


From documentation - group (aggregate) functions that operate on sets of values.. SUM returns scalar value.

Is this what you want?

SELECT MAX(duration_sum_by_cd) FROM (
  SELECT SUM(duration) duration_sum_by_cd FROM rent 
    GROUP BY cd; 
) t


that query is very broken. firstly, i don't think you can put a max around sum... 2nd you are grouping on a column "cd" which isn't in the selected columns.

I suggest doing some/many tutorials from here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜