By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE student
(`dateOfExam` date, score int)
;
INSERT INTO student
(`dateOfExam`, `score`)
VALUES
('2020-05-28',5),
('2020-05-29',5),
('2020-05-30',10),
('2020-06-03',10),
('2020-06-05',5),
('2020-07-21',20),
('2020-07-22',10),
('2020-07-28',10)
;
select date_format(dateOfExam, '%Y-%m') ExamMonth,
dateOfExam, score, "" as Reward1, "" as Reward2
from student
order by dateOfExam
ExamMonth | dateOfExam | score | Reward1 | Reward2 |
---|---|---|---|---|
2020-05 | 2020-05-28 | 5 | ||
2020-05 | 2020-05-29 | 5 | ||
2020-05 | 2020-05-30 | 10 | ||
2020-06 | 2020-06-03 | 10 | ||
2020-06 | 2020-06-05 | 5 | ||
2020-07 | 2020-07-21 | 20 | ||
2020-07 | 2020-07-22 | 10 | ||
2020-07 | 2020-07-28 | 10 |