I have a table consists of 5 columns and millions of rows. I want to capture the start and end times when the Scrap column is true (1) to calculate the total duration in minutes.
- Start Scrap-Time is when the value in the Scrap column changes from 0 to 1
- Scrap End Time is when the value in the Scrap column changes from 1 to 0.
Can you help me write an SQL query to get the following result?