SELECTing min, max (maybe length) of continuous id ranges in a table
You can apply a GROUPING AND WINDOW solution.

select min(id) as min, 
       max(id) as max,
       cust,
       load_dt,
       grp
from (
      select id, cust, load_dt, 
             sum(rst) over (order by id) as grp
      from
      (
          select id, cust, load_dt,
                 case when coalesce(lag(cust) over (order by id), '') &lt;&gt; cust then 1 end as rst
          from   foo
      ) t
     ) t
group by grp, cust, load_dt
order by 1;


This is the result:



min | max | cust  | load_dt    | grp
--: | --: | :---- | :--------- | --:
  1 |   3 | cust1 | null       |   1
  4 |   5 | cust2 | 2018-05-15 |   2
  6 |   7 | cust1 | null       |   3
  8 |   8 | cust3 | 2018-05-17 |   4



db&lt;>fiddle here