clear markdown compare help best fiddles feedback dbanow.uk a leap of faith?
clear markdown donate comments/suggestions/bugs a leap of faith? bible365 diddy dollings
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 1130678 fiddles created (16589 in the last week).

CREATE FUNCTION GetStringCount(strValue NVARCHAR2, strChar NVARCHAR2) RETURN NUMBER DETERMINISTIC IS BEGIN RETURN COALESCE((LENGTH(strValue) - LENGTH(REPLACE(strValue, strChar, ''))) / LENGTH(strChar), 0); END; /
 hidden batch(es)


CREATE TABLE example ( col NVARCHAR2(2000) );
 hidden batch(es)


INSERT INTO example (col) VALUES ('Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.');
1 rows affected
 hidden batch(es)


INSERT INTO example (col) VALUES ('At vero eos et accusam et justo duo dolores et ea rebum.');
1 rows affected
 hidden batch(es)


INSERT INTO example (col) VALUES ('Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.');
1 rows affected
 hidden batch(es)


INSERT INTO example (col) VALUES (NULL);
1 rows affected
 hidden batch(es)


SELECT GetStringCount('Hello', 'l') FROM dual;
GETSTRINGCOUNT('HELLO','L')
2
 hidden batch(es)


SELECT GetStringCount('This costs 5$.', '$') FROM dual;
GETSTRINGCOUNT('THISCOSTS5$.','$')
1
 hidden batch(es)


SELECT GetStringCount('This costs 5€.', '€') FROM dual;
GETSTRINGCOUNT('THISCOSTS5???.','???')
1
 hidden batch(es)


SELECT col, GetStringCount(col, 'a') FROM example;
COL GETSTRINGCOUNT(COL,'A')
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. 11
At vero eos et accusam et justo duo dolores et ea rebum. 3
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. 8
0
 hidden batch(es)