I have a mysql table like below,
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
In this i want to select the Points based on Quatarwise ( Jan - Mar, Apr - Jun, Jul - Sep , Oct - Dec ).
I am trying the Following Query,
$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' ";
i am getting the correct result . but what i want is ,
If any month having 2 rows of records then that particular month of records have to add and divide into 2 and sum into remaining 2 months.
Ex : Here jan month having 2 records ( 01 to 15 and 16 to 31 ) . so while getting the quarterwise result these 2 records want to add ( 4 + 5 = 9 ) and divide by 2 and take the points as jan month same for all months and finally want to get the quarterwise points.
How to do this in Mysql .