An Azure service for ingesting, preparing, and transforming data at scale.
Hello Loki,
This is an Englisch spoken forum.
Like this?
;with demoData as
(select '123456_1' as Auftrag
union all select '123456'
union all select '123456_2'
union all select '1233214'
union all select '4567890_1'
union all select '4567890_2'
union all select '4567890')
,sub as
(select case when CHARINDEX('_', Auftrag, 1) = 0
then Auftrag
else LEFT(Auftrag, CHARINDEX('_', Auftrag, 1) - 1)
End as Auftrag
from demoData)
select COUNT(*) as SplitCount, Auftrag
from sub
group by Auftrag
order by Auftrag