mysqlgroup-bymysql-error-1064

ERROR 1064 (42000): You have an error in your SQL syntax; 'DESC'


Hello, I have the following problem, I use the world.sql schema and I can't display my query in a descending way, I get the following error: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DESC'

I can't find a way to solve the problem other than storing the result in a table and then applying DESC. Could someone guide me what I could do or where I could investigate?

SELECT la.language, la.Isofficial AS Isofficial ,SUM(country.Population * la.Percentage / 100) pop_tot FROM country INNER JOIN countrylanguage AS la ON la.countryCode = country.Code WHERE  la.language != "Spanish" AND la.Isofficial = "T" GROUP BY la.Language DESC ;

Solution

  • Replace

    GROUP BY la.Language DESC;
    

    with

    GROUP BY la.Language 
    ORDER BY la.Language DESC;
    

    Which will work in whatever MySQL server version you have.

    BTW, I've tested the first syntax and it works well in version 5.5