SQL 拿最新数据

2021/9/11 19:06:44

本文主要是介绍SQL 拿最新数据,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

select device_no,data_time,so2_value,co_value,no2_value,pm10_value,pm25_value,o3_1h_value,o3_8h_value,tvoc_value 
                from default.zjk_air_quality_device_hourly_data 
                where (device_no,data_time) in (select device_no,max(data_time) 
                from default.zjk_air_quality_device_hourly_data 
                where device_class in (1,2,6,8,9) group by device_no);
SELECT device_no, grid_code, device_longitude, device_latitude, calculate_time, forecast_time, forecast_count
FROM default.alg_camera_person_forecast_hourly_data
WHERE (device_no,forecast_time,calculate_time) IN (SELECT device_no,forecast_time,max(calculate_time) 
FROM default.alg_camera_person_forecast_hourly_data
WHERE forecast_time >='2021-09-05 00:00:00' AND  forecast_time <'2021-09-06 00:00:00' 
GROUP BY  device_no,forecast_time);


这篇关于SQL 拿最新数据的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程