原址:https://www.itread01.com/p/1133452.html
SELECT A1.*
FROM tb_sensor_values AS A1
INNER JOIN (
SELECT A.m_no,A.d_time
FROM tb_sensor_values AS A
LEFT JOIN tb_sensor_values AS B
ON A.m_no = B.m_no
AND A.d_time <= B.d_time
GROUP BY A.m_no,A.d_time
HAVING COUNT(B.d_time) <= 3
) AS B1
ON A1.m_no = B1.m_no
AND A1.d_time = B1.d_time
ORDER BY A1.m_no,A1.d_time DESC
沒有留言:
張貼留言