Consecutive Row Subset Min and Max Values
Seeking a query that identifies and aggregates startt and endd values within consecutive subsets of identical act values, this question delves into data manipulation and aggregation techniques.
To approach this problem, we can utilize the following steps:
The following query implements this approach:
with cte as ( select name ,act ,row_number() over (partition by name order by name,startt) rn ,row_number() over (partition by name, act order by name,startt) act_n ,startt ,endd from input ) select name ,act ,min(startt) startt ,max(endd) endd ,min(rn) min_rn ,max(rn) max_rn from cte group by name ,act ,rn - act_n order by name ,min(rn)
The above is the detailed content of How to Find Minimum and Maximum startt and endd Values within Consecutive Subsets of Identical act Values?. For more information, please follow other related articles on the PHP Chinese website!