I need to create a query to sum values until I reach a certain amount.
select client_id, dt, SUM(value)
from my_table
group by 1, 2;
My table is something like this:
client_id | dt | value
----------+------------+-------
23 | 2023-01-01 | 200
23 | 2023-01-02 | 800
23 | 2023-01-03 | 500
My expected result is client_id: 23 | sum: 2023-01-02, that is the day that the sum reached 1000 (200 + 800).