gpt4 book ai didi

MySQL:计算每天的不同行数,包括 0

转载 作者:行者123 更新时间:2023-11-29 07:53:15 25 4
gpt4 key购买 nike

主要问题有一个很好的答案:MySQL: Count the distinct rows per day

我需要它以及还包含值但查询的日期

SELECT  DATE(timestamp) Date, COUNT(DISTINCT ipNum) totalCOunt
FROM tableName
WHERE totalCOunt < 1
GROUP BY DATE(timestamp)

给出错误(#1064 - 您的 SQL 语法有错误;请检查与您的 MySQL 服务器版本相对应的手册,以了解在 'WHERE TotalCOunt < 1 附近使用的正确语法LIMIT 0,第 3 行 25')。我哪里出错了?

此处的示例数据:http://sqlfiddle.com/#!2/11aa6/146

最佳答案

它在“where 子句”中抛出未知列“totalCOunt”错误:

请尝试以下查询(用 HAVING 子句替换 WHERE 子句):

SELECT  DATE(timestamp) Date, COUNT(DISTINCT ipNum) totalCOunt
FROM tableName

GROUP BY DATE(timestamp)
HAVING totalCOunt<1

关于MySQL:计算每天的不同行数,包括 0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25843183/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com