Link to home
Start Free TrialLog in
Avatar of Queennie L
Queennie L

asked on

Count Strings value in Column using SQL Query

how to count strings value in a column in SQL Query?

Example:

Column1                                     Count

Yes Indeed                                    2
I love Fruit                                     3
Fox Jumps Over the Fence         5

I really appreciate any help.

Thank you.
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Queennie L
Queennie L

ASKER

Thank you Bill Prew.

It is working.

Have a good day sir!
Little late, but post it anyway, now that I have typed so much in query analyser, might as well paste it here...

declare @someTable table
(
  [someColumn] varchar(100) not null
)

insert into @someTable values
 ('Yes Indeed')
,('I love Fruit')
,('Fox Jumps Over the Fence')

select [someColumn], len([someColumn]) - len(replace([someColumn], ' ', '')) + 1 [wordCount]
from @someTable

Open in new window