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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
ASKER
It is working.
Have a good day sir!