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 year(createdate) 年,month(createdate) 月,count(1) from public_cms_arcwhere (userid in (select id from cms_admin where userid='392') or userid='392')group by year(createdate),month(createdate)order by year(createdate) desc,month(createdate) desc
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
-------------------------------------------------- --数据准备 /*将数据调入临时表,对advalues进行计算,并将月份更新到字段int1 */ and advFinal is null update LinShi.dbo.Temp_Report715 set advalues = a.adv from working.dbo.adv_final as a where a.clippingid = LinShi.dbo.Temp_Report