select * into #fact_invoice_history from
(select 1 as cm_number, 'one' as cm_name, '2018-09-01 10:15:00' as dim_invoice_date
union all select 1, 'one', '2018-09-02 10:15:00'
union all select 1, 'one', '2018-09-03 10:15:00'
union all select 2, 'two', '2018-09-06 10:15:00'
union all select 2, 'two', '2018-09-07 10:15:00'
union all select 3, 'three', '2018-09-08 10:15:00') data
select * from #fact_invoice_history
-- ----------------------------------------
-- cm_number cm_name dim_invoice_date
-- ----------- ------- -------------------
-- 1 one 2018-09-01 10:15:00
-- 1 one 2018-09-02 10:15:00
-- 1 one 2018-09-03 10:15:00
-- 2 two 2018-09-06 10:15:00
-- 2 two 2018-09-07 10:15:00
-- 3 three 2018-09-08 10:15:00
-- ----------------------------------------
select
cm_number,
cm_name,
min(dim_invoice_date) min_sale_date,
max(dim_invoice_date) max_sale_date
from
#fact_invoice_history
group by
cm_number,
cm_name
-- ------------------------------------------------------------
-- cm_number cm_name min_sale_date max_sale_date
-- ----------- ------- ------------------- -------------------
-- 1 one 2018-09-01 10:15:00 2018-09-03 10:15:00
-- 3 three 2018-09-08 10:15:00 2018-09-08 10:15:00
-- 2 two 2018-09-06 10:15:00 2018-09-07 10:15:00
-- ------------------------------------------------------------
drop table #fact_invoice_history