1.简单的,按月统计数量 SELECT CREATE_DATE, DATE_FORMAT(CREATE_DATE, '%Y-%m') AS month , COUNT(*) AS sum FROM pt_user GROUP BY month; 2.按月累加统计数据 SELECT a.month, SUM(b.total) AS total FROM ( SELECT DATE_FORMAT(CREATE_DATE, '%Y-%m') AS month, SUM(sum) AS total FR
SELECT DATE_FORMAT(releaseDate,"%Y年%m月") AS dates,COUNT(*) FROM t_diary GROUP BY DATE_FORMAT(releaseDate,"%Y年%m月") ORDER BY DATE_FORMAT(releaseDate,"%Y年%m月") DESC ;releaseDate 日期 t_diary表名 DATE_FORMAT();按照格式对某个日期操作ORDER BY 排序
CREATE TABLE emp(id INT PRIMARY KEY,NAME VARCHAR(11),dep_id INT ,salary INT); CREATE TABLE dept(id INT PRIMARY KEY,NAME VARCHAR(11),parentid INT); 获取各部门人数信息: SELECT e.dep_id,d.name,COUNT(e.dep_id) FROM emp e,dept d WHERE e.dep_id=d.id GROUP BY e.dep_
select p.id comperitorId,p.compcorp competitorName, sum(case when c.kindname = 'ATM' then c.num else 0 end) atm, sum(case when c.kindname = 'CRS' then c.num else 0 end) crs, sum(case when c.kindname = 'VTM' then c.num else 0 end) vtm, sum(case when c
/** * @category * 原:strIDs in ( 100001,100002,100003,....................,110001,120001,130001,140001,150001) * 转后:( strIds in (100001,100002,100003) or strIds in (....,.....,.....) or strIds in (130001,140001,150001)) * @see 处理strIDs查找的数量超过1000时进行分
一.路由器部分 //[饼图]统计路由器在线.离线数量 SELECT COUNT(*) AS total, MINUTE)) ELSE NULL END) AS livecount, MINUTE)) ELSE NULL END) AS diecount FROM wifi_routemap 二.Portal Page页面统计部分 //[饼图]访问页面数量,以路由器进行排名 SELECT `ap_mac`, COUNT(`ap_mac`) AS `total` FROM `wifi_status_
1.按小时统计数量 SELECT TO_CHAR(RECEIVE_TIME,'HH24') HOUR ,COUNT(*) N FROM PH_PRESCRIPTION P WHERE TO_CHAR(P.RECEIVE_TIME ,'YYYY-MM-DD')='2018-12-05' GROUP BY TO_CHAR(RECEIVE_TIME,'HH24') ORDER BY TO_CHAR(RECEIVE_TIME,'HH24');