Mysql 如何在sql中修复此语法错误?
1064-您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解第3行的“按帐户排序的总资产数量\u名称限制0,30”附近使用的正确语法Mysql 如何在sql中修复此语法错误?,mysql,sql,syntax-error,Mysql,Sql,Syntax Error,1064-您的SQL语法有错误;检查与您的MySQL服务器版本对应的手册,以了解第3行的“按帐户排序的总资产数量\u名称限制0,30”附近使用的正确语法 作为总资产删除 SELECT account_name ,sum(total_balance) from transaction where account_name IN('cash','a/r','supplies','prepaid','land','gold') AS total_assets ORDER BY account_nam
作为总资产删除
SELECT account_name ,sum(total_balance) from transaction
where account_name IN('cash','a/r','supplies','prepaid','land','gold')
AS total_assets
ORDER BY account_name
你的别名放错地方了
SELECT account_name ,sum(total_balance) from transaction
where account_name IN('cash','a/r','supplies','prepaid','land','gold')
ORDER BY account_name
应该是
SELECT account_name ,sum(total_balance) from transaction
where account_name IN('cash','a/r','supplies','prepaid','land','gold')
AS total_assets
ORDER BY account_name
将
作为总资产
移动到选择
子句中。这用于定义列别名:
SELECT account_name ,sum(total_balance) AS total_assets
from transaction
where account_name IN('cash','a/r','supplies','prepaid','land','gold')
ORDER BY account_name
我想你需要给
sum(总余额)命名为总资产
select account_name, sum(total_balance) as total_assets
from transaction
where account_name in ('cash', 'a/r', 'supplies', 'prepaid', 'land', 'gold')
order by account_name;