使用MySql按日期过滤

时间:2017-05-05 20:10:00

标签: mysql

这是我实际上的查询:

SELECT month(BIL_Date) AS month,
    sum(BIL_Rate * BIL_Quantity) AS sumval
    FROM `___BillableDatas`
    WHERE BIL_HotelId = 'AAA00' 
    AND BIL_Date BETWEEN "2017-05-01" AND "2017-05-31"
    AND BIL_Type = "Night" OR BIL_Type = "Item"
    GROUP BY year(BIL_Date), month(BIL_Date);

问题是以下值,查询返回4月份的一些数据,而我想从5月1日到31日搜索。

我的错误在哪里?

我的实际表格是:

BIL_Date        BIL_Rate        BIL_Quantity        BIL_HotelId
2017-04-14      95.00           1                   AAA00
2017-04-14      16.00           2                   AAA00
2017-04-14      10.00           1                   AAA00
2017-04-15      95.00           1                   AAA00
2017-04-15      16.00           2                   AAA00
2017-04-15      10.00           1                   AAA00

感谢。

0 个答案:

没有答案