mybatis查询报错Parameter index out of range (3 > number of parameters, which is 2).

本文介绍了一个复杂的SQL查询案例,该查询用于统计不同公司业务的数据,包括案例数量、业务数量及查询数量等。通过左连接多个表,并使用条件过滤,实现了灵活的数据汇总。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<select id="getDistinctCompanyBusiness"
        parameterType="java.util.Map"
        resultType="com.qy.insurance.ls.adjust.dto.company.CompanyStatisticsResponse">

    SELECT
    e.client_name as companyName,
    d.class_name as termName,
    COUNT(a.flow_Id) as caseAmount,
    COUNT(c.id) as businessAmount,
    COUNT(b.id) as queryAmount
    FROM
    t_amount_case a
    LEFT JOIN
    t_calc_billinfo b
    ON
    a.flow_Id=b.flowId
    LEFT JOIN
    t_amount_business c
    ON
    a.flow_Id=c.flow_Id
    LEFT JOIN
    t_class d
    ON
    c.class_code=d.class_code
    LEFT JOIN
    t_client e
    ON
    a.client_code=e.client_code
    GROUP BY
    a.client_code

    <where>
        <if test="startDate != null">
            AND a.statistical_time >= #{startDate}
        </if>
        <if test="endDate != null">
            AND a.statistical_time &lt;= #{endDate}
        </if>
        <if test="client_code != '' and client_code != null">
            AND a.client_code = #{clientCode,jdbcType=VARCHAR}
        </if>
        <if test="classCode != '' and classCode != null">
            AND c.class_code = #{classCode,jdbcType=VARCHAR}
        </if>
        <if test="businessType != '' and businessType != null">
            AND a.bill_type = #{businessType,jdbcType=VARCHAR}
        </if>
    </where>

</select>

 GROUP BY

a.client_code

应该写在where后面!!!!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值