<?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="com.njcn.device.pq.mapper.OnlineRateMapper">

    <select id="getOnlineRateByDevId" resultType="OnlineRate">
        select sum(online_min)/(sum(online_min) +sum(offline_min))*100 as online_rate
        from pqs_onlinerate
        where Create_Time between #{startTime} and #{endTime}
        and
        Dev_Id IN
        <foreach item="item" collection="list" separator="," open="(" close=")">
            #{item}
        </foreach>
        group by Dev_Id ;
    </select>
</mapper>