[SOLVED] MySQL Query Building – Referral Count (same row join?)

Issue

My table looks like this:

Username     Referredby
foobar       
foobar2      foobar
lolcat       foobar
catcat       lolcat

What I want: a list of the top referrers, and how many people they have referred.

Do I need to do a self join or something?

Solution

It think you’d be okay with:

 select Referredby, count(*) from thistable 
    group by Referredby order by cnt desc;

Answered By – ethrbunny

Answer Checked By – Katrina (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *