I have problem creating valid query to aggregate over aggregate subquery. MySQL allows some non-ANSI constructs but they give incorrect results.
CREATE TABLE `log