# 1、计算每台设备总用电量 with t1 as ( select e.device_id, device_name, location, category, sum(usage_kwh) as sum_usage from energy_logs e left join smart_devices s on e.device_id = s.device_id where date(log_timestamp) between '2025-01-01' and '2025-01-31' group by 1,2,3,4 ), # 2、每个类别的平均用电量 t2 as ( select cat...