SQL – Write the query to compute the start and end of group in the giving missing sequence of number

INPUT

OUTPUT Should be

output should like this
The Logic query

select c,rownum ,c-rownum
from t_seq;

o is group1,1 is group2,2 is group 3…

Final Query

select min(c) min_range,max(c) max_range 
from t_seq
group by c-rownum
order by 1

Leave a Reply