'how to filter data by month in SQL or code
- I have data table Categories like this.
ID Data Date
1 A 2022-05-06 17:59:36
2 B 2022-05-04 13:42:55
3 C 2022-04-04 13:41:18
4 D 2022-04-04 10:46:12
5 E 2022-05-04 10:12:01
- But I want to get data and responses for user data.
month Data
5/2022: [{
ID: 1,
Data: A
},
{
ID: 2,
Data: B
}],
4/2022: [{
ID: 3,
Data: C
},
{
ID: 4,
Data: D
}],
2/2022: [{
ID: 5,
Data: E
}]
- I try group
select * from categories group by month(date)but I don't know how to continue with this. please help me with how to arrange data like this.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
