sql 语法错误 求大牛帮忙看下哪里错了
这是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