<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dromara.mapper.SenFlowDetailMapper">

    <select id="lineCharts" resultType="java.util.Map">
        SELECT DATE
        ( create_time ) AS date,
        point_name,
        SUM(
        CAST( vehicle_count AS SIGNED )) AS daily_vehicle_count
        FROM
        sen_flow_detail
        WHERE
        point_id IN (
        SELECT
        point_id
        FROM
        ( SELECT point_id, SUM( CAST( vehicle_count AS SIGNED )) AS total_vehicle_count FROM sen_flow_detail GROUP BY point_id ORDER BY total_vehicle_count DESC LIMIT 3 ) AS top_points
        )
        AND MONTH ( create_time ) = MONTH ( CURRENT_DATE )
        GROUP BY
        DATE ( create_time ),
        point_name
        ORDER BY
        DATE,
        daily_vehicle_count DESC
    </select>
</mapper>
