SELECT a.* FROM lableA INNER JOIN ( SELECT max( time ) AS time FROM lableA ) labelB ON lableA.time = labelB.time
查询labelA中,最新时间的其他数据
举例:
select b.参数类型,paravalue from (SELECT
bmp.参数类型,
bc.systemtime AS time,
bc.paravalue
FROM
buct_composedata bc,
buct_monitoring_parameters bmp,
buct_monitoring_stations bms
WHERE
bc.paraid = bmp.参数编码
AND bms.名称 = bmp.名称
AND bc.systemtime >= '2020-04-24 00:00:00'
AND bc.systemtime <= '2020-04-25 21:11:28'
AND bms.名称 = '监测站'
AND bmp.参数类型 LIKE '%表面位移%'
)result inner join (select max(time),参数类型 from (SELECT
bmp.参数类型,
bc.systemtime AS time,
bc.paravalue
FROM
buct_composedata bc,
buct_monitoring_parameters bmp,
buct_monitoring_stations bms
WHERE
bc.paraid = bmp.参数编码
AND bms.名称 = bmp.名称
AND bc.systemtime >= '2020-04-24 00:00:00'
AND bc.systemtime <= '2020-04-25 21:11:28'
AND bms.名称 = '监测站'
AND bmp.参数类型 LIKE '%表面位移%'
)c group by 参数类型
)b on result.time = b.max and result.参数类型=b.参数类型