'MySQL Query Building - Referral Count (same row join?)
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 1:[1]
It think you'd be okay with:
select Referredby, count(*) from thistable
group by Referredby order by cnt desc;
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ethrbunny |
