I have the following two select statements. The first one is:
SELECT SUM(film_payment.amount) AS Film_Income, MONTH(payment_date) AS Payment_Month
FROM film_payment
GROUP BY Payment_Month ;
And the second one is:
SELECT SUM(series_payment.amount) AS Series_Income, MONTH(payment_date) AS Payment_Month
FROM series_payment
GROUP BY Payment_Month ;
The result from the first query is:
| Film_Income | Payment_Month |
|---|---|
| 0.30 | 7 |
| 0.40 | 8 |
| 0.30 | 9 |
| 1.10 | 10 |
| 0.40 | 1 |
The result from the second query is:
| Series_Income | Payment_Month |
|---|---|
| 0.50 | 1 |
| 3.30 | 11 |
| 1.00 | 12 |
My question is, is there a way to join this two select queries to produce a table like the following?
| Payment_Month | Film_Income | Series_Income |
|---|---|---|
| 1 | NULL | 0.50 |
| 7 | 0.30 | NULL |
| 8 | 0.40 | NULL |
| 9 | 0.30 | NULL |
| 10 | 1.10 | NULL |
| 11 | 0.40 | 3.30 |
| 12 | NULL | 1.00 |
Meaning, joining them using the Payment_Month, and if one kind of income does not have a value during a month, then a NULL value should be added. Thanks in advance!