shardingsphere与mybatis配合使用,由于不支持子查询导致处理数据比较麻烦
1,如果是查询id的话,可以分两次查询,将id的值传过来
select gpu_type from xdroid_app
<where>
id in
<foreach collection="list" item="i" open="(" separator="," close=")">
#{i}
</foreach>
</where>
2,如果是统计分组数据,先将分组后的字段查出来,再通过list自动合并,同样的字段,并且数量相加功能
select `cpu` from xdroid_app where `time` between #{startTime} and #{endTime} and cpu != "" and mac_address != "00:00:00:00:00:00" group by mac_address,cpu
java中的list用下面的方法进行对数据进行处理
Map<String, Long> listMap = list.stream().collect(Collectors.groupingBy(p -> p, Collectors.counting()));