How to count instances of character in SQL Column

前端 未结 16 1701
你的背包
你的背包 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:37

    The easiest way is by using Oracle function:

    SELECT REGEXP_COUNT(COLUMN_NAME,'CONDITION') FROM TABLE_NAME
    

提交回复
热议问题