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

John 3

Mary 4

Pedro 2

But I've absolutely no idea how do do this.

Thanks in advance

Answers


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

Need Your Help

Get disassembled bytes from assembler code

assembly binary hex disassembling

I'm wondering if there is any program that can convert my assembler code into disassembled bytes like so:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.