mysql statistics usage

SELECT StatTime ,
sum(CASE WHEN StatItem like '%NHR_HOT_COUNT' THEN StatValue ELSE 0 END) as NHR_HOT_COUNT,
sum(CASE WHEN StatItem like '%NHR_NOT_HOT_COUNT' THEN StatValue ELSE 0 END) as NHR_NOT_HOT_COUNT,
sum(CASE WHEN StatItem like '%NHR_COUNT' THEN StatValue ELSE 0 END) as NHR_COUNT,
sum(CASE WHEN StatItem='TOTAL_COUNT' THEN StatValue ELSE 0 END) as TOTAL_COUNT
from rpt_stat_sum_value  
GROUP by StatTime ;


select StatTime,sum(case statItem when '2TRIP_RATIO' then FORMAT(statValue,2) end ) as 2TRIP_RATIO,
sum(case statItem when '3TRIP_RATIO' then FORMAT(statValue,2) end ) as 3TRIP_RATIO,
sum(case statItem when '4TRIP_RATIO' then FORMAT(statValue,2) end ) as 4TRIP_RATIO,
sum(case statItem when '5TRIP_RATIO' then FORMAT(statValue,2) end ) as 5TRIP_RATIO,
sum(case statItem when '6TRIP_RATIO' then FORMAT(statValue,2) end ) as 6TRIP_RATIO
from rpt_stat_sum_value where StatItem like '%TRIP_RATIO'
group by  StatTime;

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326606887&siteId=291194637