Monday, 1 August 2016

Sql query

Declare @T table(Names varchar(100))

insert into @T(Names) Values('Ashish;Pankaj;Rahul'),('Ashish;Pankaj'),('Ashish')


select * from @T




What will be count after executing the below query in Sql server 2016?

select x.value as Names,count(x.value) as Namescount
from @T
crosss apply String_Split(Names,';') x
group by x.value

No comments:

Post a Comment