有人可以帮我处理这个 sql 查询吗?它给了我一个 1064 错误,表明我的查询中有语法错误。我已经找了两个多小时的错误,现在很沮丧。
SELECT
SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 6 MONTH)) AND (`date` < DATE_SUB(?, INTERVAL 5 MONTH)), earnings, 0)) AS Rev5,
SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 5 MONTH)) AND (`date` < DATE_SUB(?, INTERVAL 4 MONTH)), earnings, 0)) AS Rev4,
SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 4 MONTH)) AND (`date` < DATE_SUB(?, INTERVAL 3 MONTH)), earnings, 0)) AS Rev3,
SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 3 MONTH)) AND (`date` < DATE_SUB(?, INTERVAL 2 MONTH)), earnings, 0)) AS Rev2,
SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 2 MONTH)) AND (`date` < DATE_SUB(?, INTERVAL 1 MONTH)), earnings, 0)) AS Rev1,
SUM(IF( (`date` >= DATE_SUB(?, INTERVAL 1 MONTH)) AND (`date` < ?), earnings, 0)) AS Rev0
FROM
hat_adsense_stats
GROUP BY
domain
ORDER BY
domain
谢谢这里是错误:
错误代码:1064 您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 2 行的 '?, INTERVAL 1 MONTH)) AND (
date
< ?),income, 0)) as Rev0 FROM hat_adsens'附近使用正确的语法