Hey guys, I have an audit table that shows when a value was changed to a specific flag ('Y', 'N', 'A', 'B') and I want to organize the data so that for each ID it'll reflect when the start and end time was for that flag.
1,Changed Flag From: N To: B,8/6/2021 2:58
1,Changed Flag From: B To: Y,8/6/2021 12:58
1,Changed Flag From: Y To: N,8/20/2021 10:58
2,Changed Flag From: Y To: N,8/1/2021 12:38
2,Changed Flag From: B To: Y,8/11/2021 10:58
ID,Flag,From Date,To Date
1,B,8/6/2021 2:58,8/6/2021 12:58
1,Y,8/6/2021 12:58,8/20/2021 10:58
2,N,8/1/2021 12:38,8/11/2021 10:58
Could you help me with this query? Thank you!