0 votes
1 view
in SQL by (36.7k points)

I have an SQL column that is a string of 100 'Y' or 'N' characters. For example:

YYNYNYYNNNYYNY...

What is the easiest way to get the count of all 'Y' symbols in each row?

1 Answer

0 votes
by (36.7k points)

If you are using SQL Server, then try this:

SELECT LEN(REPLACE(myColumn, 'N', '')) 

FROM ...

...