如何在SQL
中找到当前日期的最后三个月数据SELECT Category.name
FROM Category INNER JOIN Transaction
ON Category.categoryId = Transaction .category_id
where DATEDIFF(mm,Transaction.date, Now()) <= 3
GROUP BY Category.name
答案 0 :(得分:1)
尝试此查询。看看它是否有帮助。
SELECT `Category`.`name` FROM `Category`
INNER JOIN `Transaction`
ON `Category`.`categoryId` = `Transaction`.`category_id`
WHERE `Transaction`.`date` >= DATE_ADD(NOW(), INTERVAL -3 MONTH)
GROUP BY `Category`.`name`