I have a table which looks like this:
| id | date | user | value |
|---|---|---|---|
| 1 | 2022-07-13 16:42:33.1233 | 1 | '123' |
| 2 | 2022-07-13 16:41:33.1233 | 1 | '12345' |
| 3 | 2022-07-13 16:40:33.1233 | 1 | '12' |
| 4 | 2022-07-13 16:39:33.1233 | 1 | '12365' |
| 5 | 2022-07-13 16:37:33.1233 | 2 | '123234' |
| 6 | 2022-07-13 16:36:33.1233 | 2 | '123' |
| 7 | 2022-07-13 16:35:33.1233 | 2 | '1234' |
| 8 | 2022-07-13 16:34:33.1233 | 2 | '3234' |
| 9 | 2022-07-13 16:33:33.1233 | 3 | '1234' |
I want to get a table with each row of this one and it's user's last(by date) 3 values with a single request. Resulting table will look like that:
| id | date | user | value | last values |
|---|---|---|---|---|
| 1 | 2022-07-13 16:42:33.1233 | 1 | '123' | '12345', '12', '12365' |
| 2 | 2022-07-13 16:41:33.1233 | 1 | '12345' | '12', '12365' |
| 3 | 2022-07-13 16:40:33.1233 | 1 | '12' | '12365' |
| 4 | 2022-07-13 16:39:33.1233 | 1 | '12365' | |
| 5 | 2022-07-13 16:37:33.1233 | 2 | '123234' | '123', '1234', '3234' |
| ... | ... | ... | ... | ... |
Is there any good way to do it with PostgresSQL?