Hi All,
I have a situation where I need to select first name from a name column of this format and its count.
Schwerdtfeger, Susan CDodson, Susan I
Hubbard, Susan A
Hyde, Susan C
Mccue, Susan
Jim, Haley
Jill,Haley A
my output:
Fname Cnt
Susan 5
Haley 2
Here is my version of the script but it doesnot return quite what i want.
Select Fname, Count(*) as cnt from ( SELECT case when charindex(',', Name) > 0 Then SUBSTRING(Name, CHARINDEX(',', Name) + 2, charindex(' ', Name) -2) end as Fname FROM [namestable] dp (nolock) ) T GROUP BY FnameAny help is highly appreciated. Thanks a ton.