How do I count how many times strings from a list appear each in a query?
So basically, I have a list of distinct names, lets say
John Mary Pedro
And I have a query that returns John John Mary Pedro Mary John Pedro Mary Mary
I'd like a query that takes both of these and returns
But I've absolutely no idea how do do this.
Thanks in advance
This should be pretty straight-forward.
You need to use an aggregate function COUNT() to count the number of instances for every name.
SELECT Name, COUNT(*) AS totalCount FROM tableName GROUP BY Name