0

运行此 MySQL 查询时出现以下错误。我的问题在哪里?

#1064- 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 19 行的“INT) LIMIT 0, 30”附近使用正确的语法

select tran_date, tran_id,  
    sum(case account_id when 'M0003' then (cr_amt) else 0 end) as cr_sm,  
    sum(case account_id when 'M0003' then (dr_amt) else 0 end) as dr_sm,  
    sum(case account_id when 'M0003' then (balance) else 0 end) as bal_sm,  
    sum(case account_id when 'MD001' then (cr_amt) else 0 end) as cr_cdnw,  
    sum(case account_id when 'MD001' then (dr_amt) else 0 end) as dr_cdnw,  
    sum(case account_id when 'MD001' then (balance) else 0 end) as bal_cdnw,  
    sum(case account_id when 'MD002' then (cr_amt) else 0 end) as cr_cdw,  
    sum(case account_id when 'MD002' then (dr_amt) else 0 end) as dr_cdw,  
    sum(case account_id when 'MD002' then (balance) else 0 end) as bal_cdw,  
    sum(case account_id when 'ML001' then (cr_amt) else 0 end) as cr_loan_ord,  
    sum(case account_id when 'ML001' then (dr_amt) else 0 end) as dr_loan_ord,  
    sum(case account_id when 'ML001' then (balance) else 0 end) as bal_loan_ord,  
    sum(case account_id when 'ML002' then (cr_amt) else 0 end) as cr_loan_emg,  
    sum(case account_id when 'ML002' then (dr_amt) else 0 end) as dr_loan_emg,  
    sum(case account_id when 'ML002' then (balance) else 0 end) as bal_loan_emg  
from TEMP_MEMBER_STATEMENT  
group by tran_date, tran_id  
order by tran_date, cast(tran_id as INT);
4

1 回答 1

4

CAST 函数没有int目标。它是or ,例如。SIGNEDUNSIGNED

ORDER BY ..., CAST(tran_id AS SIGNED)
于 2012-09-03T06:03:12.893 回答