gpt4 book ai didi

mysql - 我的 MySQL 查询中的错误在哪里?

转载 作者:太空宇宙 更新时间:2023-11-03 11:05:25 24 4
gpt4 key购买 nike

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

#1064 - 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 'INT) LIMIT 0, 30' at line 19`

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);

最佳答案

CAST function 没有int 目标.它是 SIGNEDUNSIGNED,例如。

ORDER BY ..., CAST(tran_id AS SIGNED)

关于mysql - 我的 MySQL 查询中的错误在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12242716/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com