计数查询统计
Posted 亦星
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了计数查询统计相关的知识,希望对你有一定的参考价值。
CREATE TABLE `statistic_order` (
`oid` bigint(20) NOT NULL,
`o_source` varchar(25) DEFAULT NULL COMMENT ‘来源编号‘,
`o_actno` varchar(30) DEFAULT NULL COMMENT ‘活动编号‘,
`o_actname` varchar(100) DEFAULT NULL COMMENT ‘参与活动名称‘,
`o_n_channel` int(2) DEFAULT NULL COMMENT ‘商城平台‘,
`o_clue` varchar(25) DEFAULT NULL COMMENT ‘线索分类‘,
`o_star_level` varchar(25) DEFAULT NULL COMMENT ‘订单星级‘,
`o_saledep` varchar(30) DEFAULT NULL COMMENT ‘营销部‘,
`o_style` varchar(30) DEFAULT NULL COMMENT ‘车型‘,
`o_status` int(2) DEFAULT NULL COMMENT ‘订单状态‘,
`syctime_day` varchar(15) DEFAULT NULL COMMENT ‘按天格式化日期‘,
PRIMARY KEY (`oid`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8
select S.syctime_day,
sum(case when S.o_source = ‘CDE‘ then 1 else 0 end) as ‘CDE‘,
sum(case when S.o_source = ‘SDE‘ then 1 else 0 end) as ‘SDE‘,
sum(case when S.o_source = ‘PDE‘ then 1 else 0 end) as ‘PDE‘,
sum(case when S.o_source = ‘CSE‘ then 1 else 0 end) as ‘CSE‘,
sum(case when S.o_source = ‘SSE‘ then 1 else 0 end) as ‘SSE‘
from statistic_order S where S.syctime_day > ‘2015-05-01‘ and S.syctime_day < ‘2016-08-01‘
GROUP BY S.syctime_day order by S.syctime_day asc;
计数查询
SELECT r.realname ,r.start_time,r.end_time,
sum(case when r.dintype=1 then 1 else 0 end) as ‘zhong‘,
sum(case when r.dintype=2 then 1 else 0 end) as ‘wan‘
from reports r where r.start_time<‘当前时间‘ and r.end_time<‘2018-08-01‘ GROUP by r.realname,r.start_time,r.end_time ORDER by r.realname;
以上是关于计数查询统计的主要内容,如果未能解决你的问题,请参考以下文章
在c#中以编程方式查询网卡的入站/出站IPv4数据包计数统计
python 查询分析器,用于解析Redis的MONITOR命令,以获取有关查询模式的计数器/计时统计信息。 https://github.com/facebookarchive/redis-