Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in SQL by (40.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 (40.7k points)

If you are using SQL Server, then try this:

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

FROM ...

Related questions

0 votes
2 answers
0 votes
1 answer
asked Jul 13, 2019 in SQL by Tech4ever (20.3k points)
0 votes
2 answers

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...