Let’s assume there is a table:
day | amount |
---|---|
1 | 10 |
2 | 20 |
3 | 30 |
I want to know when turnover reached 30, in case above it’s happened on 2 day. How to query this in SQL? I guess I have to use window function but dont’ know which one exactly
Let’s assume there is a table:
day | amount |
---|---|
1 | 10 |
2 | 20 |
3 | 30 |
I want to know when turnover reached 30, in case above it’s happened on 2 day. How to query this in SQL? I guess I have to use window function but dont’ know which one exactly
2
Answers
You could get running Total and then put filter and limit the record with LIMIT 1 or you could use MIN for the day:
You can achieve it via aggregation