I have a table like:
date passed failed subject
2015-2-1 2 1 maths
2015-2-1 3 2 cs
2015-3-1 1 2 maths
2015-12-1 2 1 maths
I have a form for choosing a start and end date. for example: If I select startdate = 2015-2-1and enddate=2015-3-1
my output should be:
date passed failed
2015-2-1 5 3
2015-3-1 1 2
the conclusion should contain the total number of passed and unsuccessful (regardless of the subjects) for the same months as shown above.
This is the query I used:
startdate=2015-2-1andenddate=2015-3-1
SELECT SUM(passed) ,SUM(failed) FROM student_log WHERE
(DATE(`date`)='2015-2-1')
union
SELECT SUM(passed) ,SUM(failed) FROM student_log WHERE
(DATE(`date`)='2015-3-1')
It works great. But if my end date is December, I have to repeat my merge request until December ... Please suggest an alternative.
source
share