Counting length of period stored in SQL
I have a table in MariaDB that contains a population, this population is associated to a period and a person. On the population there's a boolean.
I need to calculate the lengths of those, which means if the population (that's a person and period combination) is true for 2 in a row, then the length is 2. If the last is true, then it's active, otherwise it's inactive.
I need to count all lengths, wether it's 1, 2 or more and need for every sum to know which period was the last one.
Does this makes sense?
It's okay if it's a heavy process, then I guess I just create a results table that's easy to read from, but I'm a little blank on the strategy to use here.