gpt4 book ai didi

php - 如何查找两个不同年份和月份之间的记录?

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

我尝试查找 2 个不同年份和月份之间的记录,但我的查询不起作用。这是我的查询:

SELECT product_class.sublevel AS producttype, COUNT(*) AS totalclass
FROM vtiger_classes
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_classes.classesid AND vtiger_crmentity.deleted = 0
INNER JOIN
(SELECT vtiger_product.productid, vtiger_product.sublevel_1 FROM vtiger_product
INNER JOIN vtiger_crmentity ON vtiger_crmentity.crmid = vtiger_product.productid AND vtiger_crmentity.deleted = 0) AS product_class
ON product_class.productid = vtiger_classes.Product
WHERE 1 BETWEEN MONTH(vtiger_classes.start_date) and MONTH(vtiger_classes.end_date)
AND 2019 BETWEEN YEAR(vtiger_classes.start_date) and YEAR(vtiger_classes.end_date)
GROUP BY product_class.sublevel

最佳答案

例如,要获取从 2017 年 1 月到 2018 年 12 月的所有订单:

WHERE order_date >= CAST('2017-01-01' AS DATE)
AND order_date < CAST('2019-01-01' AS DATE);

或者:

WHERE order_date >= CAST('2017-01-01' AS DATE)
AND order_date <= CAST('2018-12-31' AS DATE);

关于php - 如何查找两个不同年份和月份之间的记录?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54436389/

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