Если ваша версия СУБД 2012+
, то может использовать first_value()
функцию
with tb_LookupCode(cdValue, Desc_sup, Desc_Main) as
(
select 100000, 'FAQ','FAQ' union all
select 101000, 'Philip Fund','Philip Fund' union all
select 102000, 'LTF&RMF','LTF&RMF' union all
select 200000, 'Article','Article' union all
select 201000, 'Financial Article','Financial Article'
)
select first_value(cdValue) over
(partition by substring(cast(cdValue as varchar(25)),1,1)
order by cdValue)
as cdValue,
first_value(Desc_sup) over
(partition by substring(cast(cdValue as varchar(25)),1,1)
order by substring(cast (cdValue as varchar(25)),1,1))
as Desc_sup,
Desc_Main
from tb_LookupCode l;
cdValue Desc_sup Desc_Main
------- -------- ------------------
100000 FAQ FAQ
100000 FAQ Philip Fund
100000 FAQ LTF&RMF
200000 Article Article
200000 Article Financial Article
Rextester Demo