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
1064 - 您的SQL语法出错;查看与您的MySQL服务器版本相对应的手册,以获得正确的语法,在第3行的'account_ LIMIT 0,30'的total_assets顺序附近使用
答案 0 :(得分:1)
删除AS total_assets
SELECT account_name ,sum(total_balance) from transaction
where account_name IN('cash','a/r','supplies','prepaid','land','gold')
ORDER BY account_name
答案 1 :(得分:1)
你的别名错误。
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
答案 2 :(得分:0)
将as total_assets
移到select
子句中。这用于定义列别名:
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;