Skip to content
Advertisement

Display all the values which start with first letter of each string separated by any delimiter

I have input column name

I want the output to be with two columns

FirstLetter TotalsWordsWithThatLetter

I know recursive CTE/stuff function will be of help. But unable to write complete code.

Advertisement

Answer

This is how you can do it.

Declare a temp table with char and name, then using substring function of sql put the first character and name in the table. From there you can group the results.

Here is the sample for you for mssql server

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement