1

I have a table Units and this contain a UnitCode column. This column contains value like for ex: abbbccde

What I would like is to count the how many times character 'b' and 'c' in this value is found this value as:

 UnitCode      Character   Count
 --------------------------------
 abbbccde      b           3
 abbbccde      c           2

What I tried so far was is (Thanks to @Arul):

  SELECT REGEXP_COUNT('abbbccde', 'b') AS Result FROM dual;
  SELECT REGEXP_COUNT('abbbccde', 'c') AS Result FROM dual;

This gives the correct count. How can get it like the way I want?

  • 2
    [`REGEXP_COUNT`](https://docs.oracle.com/cd/B28359_01/server.111/b28286/functions135.htm#SQLRF20014) will help. Please find the [demo](https://dbfiddle.uk/?rdbms=oracle_18&fiddle=120f9ddb47756e825350141d238272fa) – Arulkumar Aug 14 '19 at 06:30

0 Answers0