How to count instances of character in SQL Column

前端 未结 16 1699
你的背包
你的背包 2020-11-27 12:57

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

YYNYNYYNNNYYNY...

What is the easiest way

16条回答
  •  一整个雨季
    2020-11-27 13:17

    for example to calculate the count instances of character (a) in SQL Column ->name is column name '' ( and in doblequote's is empty i am replace a with nocharecter @'')

    select len(name)- len(replace(name,'a','')) from TESTING

    select len('YYNYNYYNNNYYNY')- len(replace('YYNYNYYNNNYYNY','y',''))

提交回复
热议问题