SELECT
es.id,
es.station_name,
es.province,
es.city,
es.district,
es.detailed,
( SELECT count(*) FROM air_conditioner_equipment WHERE station_id = es.id ) AS air_conditioning_count,
( SELECT sum( cold_power ) FROM air_conditioner_equipment WHERE station_id = es.id) AS cold_power_total,
( SELECT sum( hot_power) FROM air_conditioner_equipment WHERE station_id = es.id) AS hot_power_total,
es.create_time,
es.state
FROM
energy_station es
LEFT JOIN user_station us ON us.station_id = es.id
LEFT JOIN user_info u ON u.id = us.user_id
station_id这个字段添加索引