'influx2 flux get data outside a window

I am using influx 2 and data that are structured this way in a bucket:

time         status   job_id
2022-05-09   start     1
2022-05-10   start     2
2022-05-11   end       2
2022-05-13   start     3
2022-05-12   end       3
2022-05-14   end       1

For every day, I want to know how much jobs are running using flux query. Can someone helps with the query? Despite my efforts, I do not manage to catch job_id=1 in my counter.

The expected result is:

time         count
2022-05-08   0
2022-05-09   1
2022-05-10   2
2022-05-11   2
2022-05-13   2
2022-05-12   2
2022-05-14   1
2022-05-15   0


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source