sql 语法错误 求大牛帮忙看下哪里错了

weixin_40306534 2017-12-14 11:58:25
这是sql 语句
$sql="select case when $wher then sum(FORMAT(interestamount*insure_rate/100,2)) as insure_amount else 0 end ,
case when $wher then sum(FORMAT(interestamount*insure_rate/100,2)) as insure_amountc else 0 end ,$field from jd_small_order where loan_status in(3,5) $where GROUP BY riqi";

这是打印后的语句
select case when `is_insure` in (1,2) then sum(FORMAT(interestamount*insure_rate/100,2)) as insure_amount else 0 end ,
case when `is_insure` in (1,2) then sum(FORMAT(interestamount*insure_rate/100,2)) as insure_amountc else 0 end
DATE_FORMAT(FROM_UNIXTIME(loan_time), '%Y-%m') as riqi
from jd_small_order where loan_status in(3,5) and `order_id` in (select `order_id` from `jd_agent_order` where insure_type =1) GROUP BY riqi



...全文
100 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_40306534 2017-12-14
  • 打赏
  • 举报
回复
引用 1 楼 xuzuning 的回复:
错误信息呢?
weixin_40306534 2017-12-14
  • 打赏
  • 举报
回复
xuzuning 2017-12-14
  • 打赏
  • 举报
回复
错误信息呢?
weixin_40306534 2017-12-14
  • 打赏
  • 举报
回复
引用 5 楼 xuzuning 的回复:
错误信息指出 as insure_amountc 处有问题,我想即使不去探讨语法和逻辑规则,也该直观的感知那里写错了
感谢
xuzuning 2017-12-14
  • 打赏
  • 举报
回复
错误信息指出 as insure_amountc 处有问题,我想即使不去探讨语法和逻辑规则,也该直观的感知那里写错了
xuzuning 2017-12-14
  • 打赏
  • 举报
回复
把 as insure_amount 移到 case 结构外边 CASE value WHEN [compare-value] THEN result [WHEN [compare-value] THEN result ...] [ELSE result] END CASE WHEN [condition] THEN result [WHEN [condition] THEN result ...] [ELSE result] END 这个结构现在已经被抛弃了,代之以更简洁的 IF search_condition THEN statement_list [ELSEIF search_condition THEN statement_list] ... [ELSE statement_list] END IF 结构 他们都是返回一个值,如果需要命名,自然是对返回值的命名啰

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧