It's my day 7 with SQL. I've a list of dates, I want to group them according to the month. Here's the table. It has only one column i.e. dateOfService. The format is YYYY-MM-DD.
+---------------+
| dateOfService |
+---------------+
| 2020-05-28 |
| 2020-05-29 |
| 2020-05-30 |
| 2020-06-03 |
| 2020-06-05 |
| 2020-07-21 |
| 2020-07-23 |
| 2020-07-25 |
| 2020-07-28 |
+---------------+
Ignore the DD part, i want to group these dates as follows. Something like:
+---------------+---------------+
| monthOfService| dateOfService |
+---------------+---------------+
| 2020-05 | 2020-05-28 |
| | 2020-05-29 |
| | 2020-05-30 |
|---------------|---------------|
| 2020-06 | 2020-06-03 |
| | 2020-06-05 |
|---------------|---------------|
| 2020-07 | 2020-07-21 |
| | 2020-07-23 |
| | 2020-07-25 |
| | 2020-07-28 |
+---------------+---------------+
I've to create monthOfService from dateOfService itself. It's ok if the rows in monthOfService repeats. Please tell me approach.