我想知道以下代码有什么问题:
cursor.execute("""SELECT calldate, dst, billsec, accountcode, disposition, 
                case when cast(substring(dst,4,1), unsigned) <= 5 then
                        billsec/60*%s as total
                else
                        billsec/60*%s as total
                end case
                FROM cdr where calldate >= '%s' and calldate < '%s' and disposition like '%s' and accountcode = '%s' and dst like '%s'""" %(rate_fixo, rate_movel, start_date, end_date, status, accountcode, destino))
尝试过这种方式并没有用:
cursor.execute("""SELECT calldate, dst, billsec, accountcode, disposition,
    case when cast(substring(dst,4,1), unsigned) <= 5 then 
        billsec/60*%s 
    else 
        billsec/60*%s 
    end as total
    FROM cdr where calldate >= '%s' and calldate < '%s' and disposition like '%s' 
    and accountcode = '%s' and dst like '%s'""" 
    %(rate_fixo, rate_movel, start_date, end_date, status, accountcode, destino))
错误:
“您的 SQL 语法有错误;请查看与您的 MySQL 服务器版本相对应的手册,以了解在 ' unsigned) <= 5 附近使用正确的语法,然后 billsec/60*0.1 否则 billsec/60*0.2 end as total FROM cdr w' 在第 1 行")