SQL
All Top 50 SQL Interview Questions#15
Financial Reconciliation with FULL OUTER JOIN in SQL
MediumPwCInterview Question #15
Asked at PwCYou have `bank_settlements` and `internal_ledger`. Write a SQL query using a `FULL OUTER JOIN` to show all transactions from both sources, indicating whether each transaction exists in 'Both', 'Bank Only', or 'Internal Only'.
Input Table: bank_settlements & internal_ledger
3 rows preview| bank_txn_id | internal_txn_id |
|---|---|
| TXN_101 | TXN_101 |
| TXN_102 | NULL |
| NULL | TXN_103 |
Expected Output Structure3 rows
| txn_reference | reconciliation_status |
|---|---|
| TXN_101 | Matched Both |
| TXN_102 | Bank Only |
| TXN_103 | Internal Only |
Interview Context
Asked frequently in data analyst and business analyst technical rounds. Focus on clean filtering, optimal indexing usage, and unambiguous column selection.
PostgreSQL 15
Ready to execute
Click "Run Query" or press Ctrl + Enter to test your query.
Output will be verified against the test dataset.