MariaDB: Join using derived with aggregation returns incorrect results | Hacker News Reader