`

mysql 统计使用

 
阅读更多
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;
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics