I’d like to run a query which for a given field will count the instances of a particular character.
For example if I had a table called ‘Friends’ with a ‘Names’ field containing rows: Edward, James, Mike. I’d get the output:
A 2,
D 2,
E 3,
I 1,
and so on…
The generic answer is that you need to split each name into a table of constituent characters, then count those.
You don’t mention which RDBMS you’re using. The answer varies a bit by database engine.
For example, this will work on SQL 2005+:
But almost certainly won’t work on any other database engines.