>

SQL Snippet


Using SQL to get the number of occurances of a character in a string in Oracle

This SQL Snippet can be used to get the count of a single character in a string using Oracle. We have a seperate post for doing the same thing in SQL Server. Assume you have the string a,b,c,d,e and you want the count of commas.  Just use the SQL below. Select length('a,b,c,d,e')-length(replace('a,b,c,d,e',',')) from dual; Running this query returns…