You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'ORDER BY `date` ASC LIMIT 10) AS ali GROUP BY St1 ORDER BY a1,m1,s1,j1,h1 ASC) A' at line 1