简体   繁体   English

mysql在一个月中每天获得客户端的平均值

[英]mysql getting average of client per day in a month

SELECT COUNT(client_ID) / DAY(LAST_DAY(dateRequested))
FROM `tbl_client`
WHERE dateRequested BETWEEN  DATE_FORMAT(dateRequested,'%Y-%m-01') AND LAST_DAY(dateRequested)

I want to show the average of client per day in the month 我想显示该月每天的客户平均数

client_ID   |   dateRequested
   1        |   2018-07-04
   2        |   2018-07-05
   3        |   2018-07-06
   4        |   2018-07-07
   5        |   2018-08-04
   6        |   2018-08-06
   7        |   2018-08-09

i want to show 我想展示

Average  |     Month
4        |   July 2018
3        |   August 2018

Try below query: 请尝试以下查询:

SELECT COUNT(client_ID),concat(month(dateRequested),year(dateRequested)) 
FROM `tbl_client`
WHERE dateRequested BETWEEN  DATE_FORMAT(dateRequested,'%Y-%m-01') AND LAST_DAY(dateRequested)
group by concat(month(dateRequested),year(dateRequested))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM