I have this table
---ID----NAME----INVITED_BY---
1 A
2 B 1
3 C 1
4 D 2
all I want is to get the result:
---ID----NAME------INVITES---------
1 A 2 (COUNT OF INVITED_BY)
2 B 1
3 C 0
4 D 0
You could do a self join to count the number of persons invited: