grouping rows of common values to create a new 'group id' for each set
Use DENSE_RANK function:
select
    anchor, sum(anchor) as &quot;sum&quot;, grp  as &quot;group&quot;
from
    (select 
         anchor, dense_rank() over (order by anchor) as grp
     from
         t) t1
group by
    anchor, grp
order by
    grp;



anchor | sum | group
-----: | --: | ----:
     2 |   4 |     1
     3 |   9 |     2


db&lt;&gt;fiddle here
More examples about DENSE_RANK here.
Even though it is preferable to add a new question when there is a significant change, this is the answer at your edited question.
select anchor,
       sum(anchor) as &quot;sum&quot;,
       grp as &quot;group&quot;
from (
      select anchor, dt, tm,
             sum(rst) over (order by dt, tm) as grp
      from (
            select anchor, dt, tm,
                   case when coalesce(lag(anchor) 
                                      over (order by dt, tm), 0) &lt;&gt; anchor 
                        then 1 end as rst
            from   t
           ) t1
     ) t2
group by anchor, grp
order by grp;



anchor | sum | group
-----: | --: | ----:
     2 |   4 |     1
     3 |   9 |     2
     2 |   4 |     3


db&lt;&gt;fiddle here