SQL find the count of the total character -‘n’ in Name field

There are following way to find the count of the total character – ‘n’ in the Name field in Oracle database.

  • Here we are checking occurrences of a particular character.
  • There first we have created one Employee table.
  • In that table there are 3 column Id, Name, Address field.

               Select * from Employee;

Employee total character data

Use Length function :-

  • Here, we are using the ‘Length’ function find the count of the total occurrences of a particular character.
  • Now we can subtract the total length of the Name field with a length of the Name after replacing the character – ‘n’.

Select Name, LENGTH(Name) – LENGTH(REPLACE(Name, ‘n’, ”)) As Total_Occurence from Employee;

Total occurence character