SQL语句报错

提问 未结 1 32
xsx
xsx 3天前
悬赏:20积分
版本:renren-security 开发环境:jdk1.8
SQL语句查询 SELECT ceq.id,DATE_FORMAT(cog.create_date, '%Y-%m-%d') AS create_date,SUM(cog.amount) as amount, SUM(cog.amount_envelope)as amount_envelope,SUM(cog.downmoney)as downmoney,cnt.`name` AS networkName,ceq.`name` AS devicename FROM ck_amount_log cog , ck_equipment ceq ,ck_network cnt WHERE cog.ck_equipment_id=ceq.id AND cog.ck_network_id=cnt.id and cog.ck_network_id=#{cntId} AND cog.ck_equipment_id=#{ceqId} <if test="name != null and name != ''">AND cnt.name like #{name}</if> <if test="deptId != null and deptId != ''">AND ceq.dept_id = #{deptId}</if> <if test="create_date!=null and create_date!=''">and cog.create_date &gt;=#{create_date}</if> <if test="update_date!=null and update_date!=''">and cog.create_date &lt;=#{update_date}</if> GROUP BY DATE_FORMAT(cog.create_date, '%Y-%m-%d') 变成 SELECT COUNT(1) FROM ( SELECT ceq.id, DATE_FORMAT(cog.create_date, '%Y-%m-%d') AS create_date, SUM(cog.amount) AS amount, SUM(cog.amount_envelope) AS amount_envelope, SUM(cog.downmoney) AS downmoney, cnt.`name` AS networkName, ceq.`name` AS devicename FROM ck_amount_log cog, ck_equipment ceq, ck_network cnt WHERE cog.ck_equipment_id = ceq.id AND cog.ck_network_id = cnt.id AND cog.ck_network_id = ? AND cog.ck_equipment_id = ? GROUP BY DATE_FORMAT(cog.create_date, '%Y-%m-%d') ) TOTAL
回帖
  • 这个SQL不是我们写的,在公司里面,找下对应的开发人员 face[哈哈]
    0 回复