Suppose we have the below table and data

--Declare the table variable
DECLARE @T TABLE(Names VARCHAR(100))

-- Insert Some Value
INSERT INTO @T (Names)
VALUES ('Niladri;Arina;Rajlaxmi'),('Niladri;Arina'),('Niladri')

-- Retrieve data
SELECT *
FROM @T

After execution the result is

Names
---------
Niladri;Arina;Rajlaxmi
Niladri;Arina
Niladri

What will be the count of "Niladri","Arina","Rajlaxmi" after executing the below query in SQL Server 2016?

SELECT X.value AS Names, COUNT(X.value) AS NamesCount
FROM @T
CROSS APPLY STRING_SPLIT(Names,';') X
GROUP BY X.value

 Posted by Rajnilari2015 on 6/8/2016 | Category: Sql Server Interview questions | Views: 3871 | Points: 40
Select from following answers:
  1. 3,2,1
  2. 2,3,1
  3. 1,2,3
  4. 3,1,2
  5. All Above

Show Correct Answer


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response