I am trying to learn Microsoft SQL Server and I'm trying to figure out how I can do the following.
I have two tables:
users
id fname lname username
111 kely dike kdike
222 hana sho hsho
333 mike dime mdime
444 sergi xan sxan
and
email_recipient
id recipient_id fname lname
1 222 hana sho
2 222 hana sho
3 222 hana sho
4 333 mike dime
5 111 kely dike
6 111 kely dike
7 444 sergi xan
8 444 sergi xan
9 444 sergi xan
10 444 sergi xan
and what I want to do is to count how many emails each user received, something like this:
id fname lname username email_recipient total
111 kely dike kdike 2
222 hana sho hsho 3
333 mike dime mdime 1
444 sergi xan sxan 4
Could someone please point in the right direction?