数据库查询,按年月排序,计算每月、当年每月有几条数据
数据库查询,按年月排序,计算每月有几条数据
数据库查询,按年月排序,计算当年每月有几条数据
SELECT DATE_FORMAT(inspection_date,'%Y-%m') AS DATETIME, count(*) AS num FROM gw_inspection_data t1 WHERE YEAR(inspection_date) = YEAR(CURDATE()) GROUP BY DATE_FORMAT(inspection_date,'%Y-%m')