cindi cindi - 1 year ago 51
SQL Question

How to count instances of character in SQL Column

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


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

Answer Source

if ms sql

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