sql query to calculate the number of da

Job ID: 30659567

Budget: $30 – $250 USD

in a stock history table, the Erp keeps each stock movement input or output in a history (a single STOJOU table) per date and time.

This is called a fifo battery.

the system cumulates the movements by +movements and - .

the objective has each time the stock goes to 0 I want to know the date or the stock has gone to 0 and the number of times per month in days that this stock has gone to 0. group by item.

in the example attached this article to known a break--> stock=0 on 19/05/2021, so the result of the request would be dated break to 1/05, the number of break days of the month of April 5 days .

sorry I formula, false maybe I am French I use an automatic translator:)