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


My table looks like this:

Username     Referredby
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?


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 *