Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql:如何查询所有用户每天创建的记录?_Mysql_Database_Group By - Fatal编程技术网

Mysql:如何查询所有用户每天创建的记录?

Mysql:如何查询所有用户每天创建的记录?,mysql,database,group-by,Mysql,Database,Group By,我的表格包含以下数据: 正如您所看到的,上表有用户id,并在列中创建了。我想查询如下所示的数据 我使用了下面的查询,但它在任何日期都只提供1个用户的数据 e用户\u id不为空 按日期分组(创建于) [![在此处输入图像描述][3][3] 如您所见,它一次只显示一个用户的数据。 请提供帮助。在group by子句中包含用户id,以获取每个日期和每个用户的数据 SELECT count(*) AS 'Requests', DATE(created_at) AS 'Date', user_id FR

我的表格包含以下数据:

正如您所看到的,上表有用户id,并在列中创建了。我想查询如下所示的数据

我使用了下面的查询,但它在任何日期都只提供1个用户的数据

e用户\u id不为空 按日期分组(创建于)

[![在此处输入图像描述][3][3]

如您所见,它一次只显示一个用户的数据。
请提供帮助。

在group by子句中包含
用户id
,以获取每个日期和每个用户的数据

SELECT count(*) AS 'Requests',
DATE(created_at) AS 'Date',
user_id
FROM ibiza_production.line_write_revenues where user_id is not null
GROUP BY DATE(created_at),user_id;

试着用concat分组

SELECT `date`,`user_id`,COUNT(*) FROM ibiza_production.line_write_revenues GROUP BY CONCAT(`date`,'-',`user_id`) ORDER BY `date`,`user_id` LIMIT 50

嗨,你能试试这个吗?如果它对你有帮助,请告诉我

SELECT count(*) AS 'Requests',
DATE(created_at) AS 'Date',user_id
FROM ibiza_production.line_write_revenues where user_id is not null
GROUP BY DATE(created_at),user_id order by DATE(created_at);

您需要将用户添加到分组依据。
SELECT count(*) AS 'Requests',
DATE(created_at) AS 'Date',user_id
FROM ibiza_production.line_write_revenues where user_id is not null
GROUP BY DATE(created_at),user_id order by DATE(created_at);