I have a table with three columns (apart from the id):
- topic
- user
- ip
Topic cannot be null, but the other two can. There are no unique restrictions.
So an example of data would be this:

What I want to get is the distinct combination of user and ip, and count the resulting rows grouped by topic:

EDIT:
Ok, the first popular answer is:
SELECT topic, COUNT(IP)
FROM MyTable
GROUP BY topic;
But I see you are ignoring the user column, why? Maybe my example was not good 🙂
Let’s add a new record:

Running the above query would give us the same result, but it is wrong:
SELECT DISTINCT topic, user, ip FROM MyTable;
It returns:

So in this case the totals would be:

Sample:
For the edited question: