How do you perform a full outer join on `txn_id` and flag rows where either side is missing?
1Times asked
Sep 2026Last seen
Sep 2026First seen
💡 Model Answer
Use a FULL OUTER JOIN on the key column and add a CASE expression to flag missing rows. For example:
SELECT
COALESCE(a.txn_id, b.txn_id) AS txn_id,
a.notional AS a_notional,
b.notional AS b_notional,
CASE
WHEN a.txn_id IS NULL THEN 'not in txn_a'
WHEN b.txn_id IS NULL THEN 'not in txn_b'
ELSE 'present in both'END AS status
FROM txn_a a
FULL OUTER JOIN txn_b b ON a.txn_id = b.txn_id;
The COALESCE ensures you get the txn_id from whichever side is present, and the CASE expression labels rows that exist only in one table.
This answer was generated by AI for study purposes. Use it as a starting point — personalize it with your own experience.
🎤 Get questions like this answered in real-time
Assisting AI listens to your interview, captures questions live, and gives you instant AI-powered answers on a discreet on-screen overlay.
Get Assisting AI — Starts at ₹500