Select data within one month prior to each user's last record
问题 Assume I have a table called "Diary" like this: | id | user_id | recorded_at | record | |----|---------|--------------------------|--------| | 20 | 50245 |2017-10-01 23:00:14.765366| 89 | | 21 | 50245 |2017-12-05 10:00:33.135331| 97 | | 22 | 50245 |2017-12-31 11:50:23.965134| 80 | | 23 | 76766 |2015-10-06 11:00:14.902452| 70 | | 24 | 76766 |2015-10-07 22:40:59.124553| 81 | For each user I want to retrieve the latest row and all rows within one month prior to that. In other words, for user_id