mysql关联查询

SELECT t1.res_id,t1.kpi_id,t.`id` AS thid,t1.hostname,t1.kpi_show_name,t1.dataValue
FROM
(SELECT m.res_id,m.kpi_id,m.hostname,m.kpi_show_name,AVG(m.indexValue) AS dataValue
FROM 
(SELECT 
r.`id` AS res_id,k.`id` AS kpi_id,p.`dateday`,p.`timeday`,p.`hostname`,k.`kpi_show_name`,CONCAT(p.dateday,' ',p.timeday) AS newtime ,p.`indexName`,p.`indexValue`
FROM `t_ovo_host_performance` p ,`business_resource_info` r,`resource_kpis` k
WHERE p.`hostname` = r.`hostname` AND k.`kpi_name` = p.`indexName` AND r.`id`=1) AS m 
WHERE m.newtime>='2016-07-11 00:00' AND m.newtime<='2016-07-30 00:00'
GROUP BY m.kpi_show_name) AS t1 LEFT JOIN `threshold_task` t ON t1.res_id = t.res_id AND t1.kpi_id = t.`kpi_id`
展开阅读全文

没有更多推荐了,返回首页