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
精彩评论