Reputation: 21
I have multiple tables with an account number and a dollar amount.
Table Name: July Accounts
| Account Number | Amount |
|------------------|--------|
| 1111111111111111 | $99.00 |
Table Name: August Accounts
| Account Number | Amount |
|------------------|--------|
| 2222222222222222 | $89.00 |
I want my results to display as:
| Account Number | July | August |
|------------------|--------|--------|
| 1111111111111111 | $99.00 | - |
| 2222222222222222 | - | $89.00 |
So far everything I've tried causes something along the lines of:
| Account Number | July | August |
|------------------|--------|--------|
| 1111111111111111 | $99.00 | $89.00 |
| 1111111111111111 | $99.00 | $99.00 |
| 1111111111111111 | $89.00 | $89.00 |
| 1111111111111111 | $89.00 | $99.00 |
| 2222222222222222 | $99.00 | $89.00 |
| 2222222222222222 | $99.00 | $99.00 |
| 2222222222222222 | $89.00 | $89.00 |
| 2222222222222222 | $89.00 | $99.00 |
Any suggestions?
Upvotes: 1
Views: 36
Reputation: 30800
You just need to use UNION:
SELECT Account_Number, Amount as July, null as August
FROM July_Accounts
UNION
SELECT Account_Number, null, Amount
FROM August_Accounts
Upvotes: 2