数据库结构
CREATE TABLE installs(
id INT, PRIMARY KEY(id),
created DATETIME)
CREATE TABLE uninstalls(
id INT, PRIMARY KEY(id),
created DATETIME,
install_id INT)
查询(“我与 MySQL”)
SELECT DATE(installs.created),
COUNT(installs.id),
COUNT(uninstall.id)
FROM installs
LEFT JOIN uninstalls ON uninstalls.install_id = installs.id
GROUP BY DATE(installs.created)
“预期”输出
DATE(installs.created) | COUNT(installs.id) | COUNT(uninstalls.id)
2012-11-20 | *installs on date* | *uninstalls on date*
所以 - 我每天都在查看当天发生的安装/卸载次数。
问题
每天的“安装”数据都是正确的。但遗憾的是,每天“卸载”的数据不正确。