I have 3 tables. 1 table houses the ID and the name for the ID. Like 1 and 1 is John Doe. The 2nd table is a grouped by table of all the letters that were sent out to John Doe and they are duplicate letters due to they are sent every day of the month. But the letters fall under a recipient member. The other table is the same thing but it falls under provider. I want to take and run a query to show all the letters for John Doe with the ID of 1 and have the first column the ID, 2nd column John Doe, 3rd column letter name for provider, 4th column letter count, 5th column letter name for member, 6th column letter count. But it has to be aggregate for the entire month. So if I am querying say Jun08, it would look like this:

1 john doe bill001 2 bill001 3
1 john doe bill002 3 bill002 4
1 john doe cob001 5
1 john doe recon002 5


Now the issue is I did my group by the template name and did the count so I have 1 table for all provider stuff. Then another table to get the member recipient. But when running the query, it will revert back to single counts. If I just run the provider table with the ID table it does it right and vice versa. But the provider and member don't always get the same letter type. So I want the query to look at the ID and place the letter type and numbering where it should go. So when I am done it should look like the above in the end.

I thought I could use the ID as primary key, then connect to ID in the provider and member table and in the criteria put also where p.templatename = m.templatename. But not sure if that is correct.