{"id":7407,"date":"2024-11-14T08:16:46","date_gmt":"2024-11-14T00:16:46","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7407\/"},"modified":"2024-11-14T08:16:46","modified_gmt":"2024-11-14T00:16:46","slug":"%e5%a6%82%e4%bd%95%e9%ab%98%e6%95%88%e8%8e%b7%e5%8f%96%e4%b8%80%e5%af%b9%e5%a4%9a%e5%85%b3%e7%b3%bb%e4%b8%ad%e8%ae%be%e5%a4%87%e7%9a%84%e6%9c%80%e6%96%b0%e7%8a%b6%e6%80%81%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7407\/","title":{"rendered":"\u5982\u4f55\u9ad8\u6548\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u8bbe\u5907\u7684\u6700\u65b0\u72b6\u6001\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173079702430946.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u9ad8\u6548\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u8bbe\u5907\u7684\u6700\u65b0\u72b6\u6001\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u9ad8\u6548\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u8bbe\u5907\u7684\u6700\u65b0\u72b6\u6001\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4e00\u5bf9\u591a\u67e5\u8be2\u4f18\u5316\uff1a\u9ad8\u6548\u83b7\u53d6\u8bbe\u5907\u6700\u65b0\u72b6\u6001<\/strong><\/p>\n<p>\u5728\u5904\u7406\u5173\u8054\u8868\u67e5\u8be2\u65f6\uff0c\u5982\u4f55\u9ad8\u6548\u5730\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u6700\u65b0\u7684\u4e00\u6761\u8bb0\u5f55\u662f\u4e00\u5927\u96be\u9898\u3002\u9488\u5bf9\u6b64\u9700\u6c42\uff0c\u6709\u4ee5\u4e0b\u4f18\u5316\u65b9\u6848\uff1a<\/p>\n<p><strong>\u5185\u8fde\u63a5\u67e5\u8be2<\/strong><\/p>\n<pre>select * from (select * from air_conditioner_record order by req_timestamp desc) as r group by air_conditioner_id order by req_timestamp desc<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u65b9\u6848\u901a\u8fc7\u5185\u8fde\u63a5\u81ea\u8fde\u63a5\uff0c\u5c06\u6240\u6709\u8bbe\u5907\u8bb0\u5f55\u6309\u7167\u65f6\u95f4\u5012\u5e8f\u540e\u5206\u7ec4\uff0c\u518d\u6309\u7167\u65f6\u95f4\u5012\u5e8f\u6392\u5217\uff0c\u4ece\u800c\u5f97\u5230\u6bcf\u53f0\u8bbe\u5907\u7684\u6700\u65b0\u8bb0\u5f55\u3002<\/p>\n<p><strong>\u65f6\u95f4\u7a97\u53e3\u67e5\u8be2<\/strong><\/p>\n<pre>SELECT\n                r.air_conditioner_id,\n                r.curr_temp,\n                r.curr_power,\n                r.time_millis\n            FROM\n                air_conditioner_record r,\n            ( SELECT air_conditioner_id, max( time_millis ) max_time FROM air_conditioner_record WHERE time_millis &lt; UNIX_TIMESTAMP(NOW()) GROUP BY air_conditioner_id ) r2\n            WHERE\n                r2.air_conditioner_id = r.air_conditioner_id\n            AND r2.max_time = r.time_millis<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u65b9\u6848\u521b\u5efa\u4e86\u4e00\u4e2a\u65f6\u95f4\u7a97\u53e3\uff0c\u4ec5\u8003\u8651\u5f53\u524d\u65f6\u95f4\u4e4b\u524d\u7684\u8bb0\u5f55\uff0c\u5e76\u5728\u8be5\u7a97\u53e3\u5185\u627e\u5230\u6bcf\u53f0\u8bbe\u5907\u7684\u6700\u65b0\u8bb0\u5f55\u3002\u8fd9\u79cd\u65b9\u6cd5\u9ad8\u6548\u4e14\u7b80\u6d01\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u9ad8\u6548\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u8bbe\u5907\u7684\u6700\u65b0\u72b6\u6001\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u5bf9\u591a\u67e5\u8be2\u4f18\u5316\uff1a\u9ad8\u6548\u83b7\u53d6\u8bbe\u5907\u6700\u65b0\u72b6\u6001 \u5728\u5904\u7406\u5173\u8054\u8868\u67e5\u8be2\u65f6\uff0c\u5982\u4f55\u9ad8\u6548\u5730\u83b7\u53d6\u4e00\u5bf9\u591a\u5173\u7cfb\u4e2d\u6700\u65b0\u7684\u4e00\u6761\u8bb0\u5f55\u662f\u4e00\u5927\u96be\u9898\u3002\u9488\u5bf9\u6b64\u9700\u6c42\uff0c\u6709\u4ee5\u4e0b\u4f18\u5316\u65b9\u6848\uff1a \u5185\u8fde\u63a5\u67e5\u8be2 select * from (select * from air_conditioner_record order by req_timestamp desc) as r group by air_conditioner_id order by req_timestamp desc \u767b\u5f55\u540e\u590d\u5236 \u6b64\u65b9\u6848\u901a\u8fc7\u5185\u8fde\u63a5\u81ea\u8fde\u63a5\uff0c\u5c06\u6240\u6709\u8bbe\u5907\u8bb0\u5f55\u6309\u7167\u65f6\u95f4\u5012\u5e8f\u540e\u5206\u7ec4\uff0c\u518d\u6309\u7167\u65f6\u95f4\u5012\u5e8f\u6392\u5217\uff0c\u4ece\u800c\u5f97\u5230\u6bcf\u53f0\u8bbe\u5907\u7684\u6700\u65b0\u8bb0\u5f55\u3002 \u65f6\u95f4\u7a97\u53e3\u67e5\u8be2 SELECT r.air_conditioner_id, r.curr_temp, r.curr_power, r.time_millis FROM air_conditioner_record r, ( SELECT air_conditioner_id, max( time_millis ) max_time FROM air_conditioner_record WHERE time_millis &lt; UNIX_TIMESTAMP(NOW()) GROUP BY air_conditioner_id ) r2 WHERE r2.air_conditioner_id = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-7407","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7407","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=7407"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7407\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7407"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7407"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7407"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}