cindi cindi - 2 years ago 61
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 ...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download