gunshi-project-ss/src/main/resources/mapper/StWaterRRealMapper.xml

27 lines
936 B
XML

<?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.gunshi.project.hsz.mapper.StWaterRRealMapper">
<select id="listRelated" resultType="com.gunshi.project.hsz.model.StWaterRReal">
SELECT
stb.stcd,
stb.sttp,
stb.stnm,
t.tm,
t.q,
t.v
FROM public.st_stbprp_b stb
JOIN public.st_water_r_real t ON t.stcd = stb.stcd
JOIN (
SELECT stcd, MAX(tm) as max_tm
FROM public.st_water_r_real
GROUP BY stcd
) latest ON t.stcd = latest.stcd AND t.tm = latest.max_tm
<where>
<!-- stb.sttp in ('QQ', 'PQ','ZI') 站点类型 站点编码是唯一的,所以不用对类型进行 -->
and stb.stcd in ('1112','1113','1114') <!-- 站点编码 -->
</where>
</select>
</mapper>