join two tables with views? I have two content types: one for invoices, and the other for donations. 

Each content type contain two fields, one for "User Name" (which is a user reference type) and the other is the "Amount($)" (an integer type).

I am trying to create a table with the Views module that returns 3 columns: user name, total donation (the sum for all the donation for the same user), and invoice sum (the sum of all the amount paid for the same user).

I have two users (Ahmed and Taha). Ahmed made 3 donations ($50, $30 and $70) and paid 2 invoices ($30, $30); Taha made 1 donation ($60), and paid 3 invoices ($30, $30, $30). 

What I am trying to achieve with the Views module is something like the following.


    *----------------*------------------------*-------------------------*
    |   Username     | Total Donations        | Total Subscriptions     |
    *----------------*------------------------*-------------------------*
    |   Ahmed        |     $150               |      $60                |
    *----------------*------------------------*-------------------------*
    |   Taha         |     $60                |       $90               |
    *----------------*------------------------*-------------------------*


or Something like:


    *----------------*------------------------*-------------------------*
    |   Username     | Donations              | Subscriptions           |
    *----------------*------------------------*-------------------------*
    |   Ahmed        |     $50                |      $30                |
    *----------------*------------------------*-------------------------*
    |   Ahmed        |     $30                |      $30                |
    *----------------*------------------------*-------------------------* 
    |   Ahmed        |     $70                |       ---               |
    *----------------*------------------------*-------------------------*
    |   Taha         |     $60                |       $30               |
    *----------------*------------------------*-------------------------* 
    |   Taha         |     ---                |       $30               |
    *----------------*------------------------*-------------------------*
    |   Taha         |     ---                |       $30               |
    *----------------*------------------------*-------------------------*
To add Joins to your views using the Views UI you will need to open the Advanced settings and visit Relationships. (See graphic)



Assuming the user is the author ($node->uid) of the donation's and subscription's payment types you should be able to use the "Content: Author" field to accomplish this join.



This should allow you to build the second table from your question.  To see results displayed in a similar format to your first table you will need to use aggregation.  'Use Aggregation' can be found under the Advanced menu.



Once use aggregation is enabled you will see a new link below your fields called "Aggregation settings."

Select SUM on the field you want to display the totals for and you should see something similar to your first table.



Lastly, while you are getting aquanted with the Views module I recommend turning on the "Show the SQL query" feature in Views settings.  This can be found at admin/structure/views/settings 

This will show you the SQL views is generating which can be useful while debugging or learning the Views UI.