OTA-数据完整性分析【生产者车辆升级过程完整性分析】修改为全部数据排名

这个SQL查询用于从多个表格中联合分析汽车日志的完整性。它通过LEFT JOIN操作连接`car_corp`表和每个`tableNameList`中的表格,并使用IFNULL函数处理可能为NULL的日志总数。查询还包含条件过滤,如开始和结束日期,以获取特定时间段内的不完整记录数和日志总数。最后,根据不完整记录数进行排序并限制返回结果的前10条记录。
摘要由CSDN通过智能技术生成

CarCorpMapper.xml

IFNULL(temp.logTotal,0)

<select id="carLogIntegrityAnalysis" resultMap="carLogIntegrityAnalysisMap">
        SELECT cc.corp_cname,IFNULL(temp.logTotal,0) as logTotal,IFNULL(temp.integrityLogNums,0) as integrityLogNums,temp.incomcnt,temp.type
        FROM car_corp cc
        LEFT JOIN
        (
        <foreach collection="tableNameList" item="tableName" separator="UNION">
            (
            SELECT
            t.*
            , ( SELECT COUNT(*) FROM ota_report_flow as orf LEFT JOIN ${tableName} as l ON orf.record_num = l.record_num
            ANd orf.audit_state = 2
            WHERE l.incomp_field IS NOT NULL AND l.incomp_field != ''
            <if test="@com.zhuoqin.common.utils.Ognl@isNotEmpty(query.beginDate)">and orf.report_time &gt;=
                DATE_FORMAT(#{query.beginDate}, '%Y-%m-%d')
            </if>
            <if test="
            @com.zhuoqin.common.utils.Ognl@isNotEmpty(query.endDate)">and orf.report_time &lt;=
                DATE_FORMAT(#{query.endDate}, '%Y-%m-%d')
            </if>
                ) as integrityLogNums
                , (
                    SELECT COUNT(*) FROM
                    ota_report_flow as orf LEFT JOIN ${tableName} as l ON orf.record_num = l.record_num
                    ANd orf.audit_state = 2
                    <where>
                        <if test="@com.zhuoqin.common.utils.Ognl@isNotEmpty(query.beginDate)">
                            and l.upload_time &gt;= DATE_FORMAT(#{query.beginDate}, '%Y-%m-%d')
                        </if>
                        <if test="@com.zhuoqin.common.utils.Ognl@isNotEmpty(query.endDate)">
                            and l.upload_time &lt;= DATE_FORMAT(#{query.endDate}, '%Y-%m-%d')
                        </if>
                    </where>
                ) as logTotal
                ,COUNT(t.vin_num) as incomcnt
                FROM (
                    SELECT DISTINCT
                    orf.record_num
                    ,ci.car_nums
                    ,l.vin_num
                    ,cc.corp_cname
                    ,substring_index( substring_index( l.incomp_field, ',', rr.id + 1 ), ',',-1 ) AS type
                    FROM ota_report_flow as orf
                    LEFT JOIN ${tableName} as l ON l.record_num = orf.record_num
                    LEFT JOIN row2rows as rr ON rr.id &lt; ( length( l.incomp_field ) - length( REPLACE ( l.incomp_field, ',',
                    '' )) + 1 )
                    LEFT JOIN car_corp as cc on cc.cpid = orf.cpid
                    LEFT JOIN car_info as ci ON ci.record_num = orf.record_num
                    WHERE orf.audit_state = 2
                    AND l.incomp_field IS NOT NULL AND l.incomp_field != ''
                    <if test="@com.zhuoqin.common.utils.Ognl@isNotEmpty(query.beginDate)">
                        and orf.report_time &gt;= DATE_FORMAT(#{query.beginDate}, '%Y-%m-%d')
                    </if>
                    <if test="@com.zhuoqin.common.utils.Ognl@isNotEmpty(query.endDate)">
                        and orf.report_time &lt;= DATE_FORMAT(#{query.endDate}, '%Y-%m-%d')
                    </if>
                ) as t
                GROUP BY type
                ORDER BY incomcnt ${query.sortType}
                LIMIT 10
            )

        </foreach>
         )temp
        on cc.corp_cname = temp.corp_cname
    </select>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值