我有一个如下所示的mysql表,
Test :
Id start_Date End Date Points
1 01-01-2017 15-01-2017 4
2 01-02-2017 28-02-2017 5
3 16-01-2017 31-01-2017 5
4 01-03-2017 15-03-2017 3
5 16-03-2017 31-03-2017 4
6 01-04-2017 30-04-2017 5
在此我想根据Quatarwise(1月 - 3月,4月 - 6月,7月 - 9月,10月 - 12月)选择积分。
我正在尝试以下查询,
$q1 = "select sum(points) as point from Test where month(start_Date) Between '00' and '03' ";
$q2 = "select sum(points) as point from Test where month(start_Date) Between '04' and '06' ";
$q3 = "select sum(points) as point from Test where month(start_Date) Between '07' and '09' ";
$q1 = "select sum(points) as point from Test where month(start_Date) Between '10' and '12' ";
我得到了正确的结果。但我想要的是,
如果任何一个月有2行记录,则该特定月份的记录必须添加并分成2并且总计为剩余的2个月。
例如:这里1月有2条记录(01至15和16至31)。因此,在得到季度结果的同时,这2条记录想要添加(4 + 5 = 9)并除以2,并将所有月份的点数视为jan月相同,最后想得到季度点数。
如何在Mysql中执行此操作。