我的参赛作品有时间戳,如1488446089,1469525148等。
我正在尝试获取不超过30天的条目。 另一个用例是获取条目> =年(2016)
这个查询有什么问题。它返回所有结果,忽略where子句
"SELECT DATE(FROM_UNIXTIME(createdTime)) AS ForDate,
COUNT(*) AS NumPosts
FROM Posts
WHERE DATE_SUB(from_unixtime(createdTime), INTERVAL 30 DAY)
GROUP BY DATE(FROM_UNIXTIME(createdTime))
ORDER BY ForDate"
答案 0 :(得分:2)
似乎你没有过滤器(yoy不比较值),例如date_sub(...) >= DATE(FROM_UNIXTIME(createdTime))
"SELECT DATE(FROM_UNIXTIME(createdTime)) AS ForDate,
COUNT(*) AS NumPosts
FROM Posts
WHERE DATE_SUB(from_unixtime(createdTime), INTERVAL 30 DAY) >= DATE(FROM_UNIXTIME(createdTime))
GROUP BY DATE(FROM_UNIXTIME(createdTime))
ORDER BY ForDate"