1:
SQL formater does not work on some queries when values are being calculated using several SQL functions and assigned (with AS) to some alias/name, eg. “SELECT … SUM(…)/COUNT(…) AS …”
Example:
Code:
SELECT SUM(LENGTH(User))/COUNT(*) AS AverageNameLength FROM mysql.user;
the formatter works, though, when the formula is in brackets:
Code:
SELECT (SUM(LENGTH(User))/COUNT(*)) AS AverageNameLength FROM mysql.user;
2 (related):
SQL formater works “strangely” when same queries without “AS”.
Example:
Code:
SELECT COUNT(*), SUM(LENGTH(User))/COUNT(*) FROM mysql.user;
this will be converted to:
Code:
SELECT
COUNT(*),
SUM(LENGTH(User)) /COUNT(*)
FROM mysql.user;
(note spaces before “/COUNT(*)”)