SHOWcode

2020年4月1日 星期三

MySQL獲取所有分類和每個分類的前N條記錄


原址: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

沒有留言:

張貼留言

Jenkins-mail

參考:http://www.linuxea.com/1767.html 前置作業略過~有空再補 Mailer Plugin post { success { emailext ( subject: &...