Use row_number()
to generate a sequence and subtract from value
. That is a constant for the groups you want:
select element, min(value), max(value)
from (select t.*,
row_number() over (partition by element order by value) as seqnum
from t
) t
group by element, (value - seqnum)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.