如题,当sql中出现group by时这时其他非分组字段只能带函数才能出现在select列中,所以最好的办法只能连表去查询其他字段
@Select("<script>" + "select A.* from sc_potable_water_sources_monitor_hour A INNER JOIN ( SELECT C.station_name AS stationName, max(C.data_time) AS dataTime " + "FROM sc_potable_water_sources_monitor_hour C where C.station_name in " + "<foreach item='item' index='index' collection='stationNameList' open='(' separator=',' close=')'> #{item} </foreach>"+ "GROUP BY C.station_name ) r ON A.station_name = r.stationName " + "AND A.data_time = r.dataTime " + "</script>") List<ScPotableWaterSourcesMonitorHourDO> selectAppMapData(@Param("stationNameList") Collection<String> stationNameList);
标签:group,name,查询,station,分组,sql From: https://www.cnblogs.com/Yoona520/p/17000205.html