首页 > 解决方案 > 我的查询需要超过 30 分钟,即使它会显示结果也不确定

问题描述

下面给出的是查询:

SELECT  
   states.name, 
   equipment.type, 
   sum(equipment_events.total), 
   (SUM(equipment_locations.amount) - SUM(equipment_events.total)) 
FROM 
   States, 
   Locations,
   Equipment_locations, 
   equipment, 
   equipment_events, 
   events 
WHERE 
   equipment.id = equipment_events.equipment_id 
   and states.id = locations.state_id 
   and locations.id = events.location_id 
   and equipment.id = equipment_events.equipment_id 
GROUP BY  
   states.name;

标签: sql

解决方案


推荐阅读