I have a table like this
| id | date | capacity | depot | reserved | order_id
| 1 | 2024-04-29 | 69 | 1 | 0 | 0 |
| 2 | 2024-04-29 | 49 | 1 | 0 | 0 |
| 3 | 2024-04-29 | 69 | 1 | 0 | 0 |
| 4 | 2024-04-29 | 69 | 1 | 0 | 0 |
Now I want to get only row where the sum of “capacity” is nearly to 100 – so my output should be
| id | date | capacity | depot | reserved | order_id
| 1 | 2024-04-29 | 69 | 1 | 0 | 0 |
| 2 | 2024-04-29 | 49 | 1 | 0 | 0 |
Could you help me find the correct SQL statement?
I tried already to sum the capacity and group it by id with having sum >= 100 but I still get no results
Erik is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.