FULL OUTER JOIN — Complete Guide
FULL OUTER JOIN — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of SQL Server Tutorial on Toolliyo Academy.
On this page
SQL Server Tutorial · Lesson 24 of 100
FULL OUTER JOIN
SQL basics → Queries → Advanced
SQL basics · 1 — SELECT · ~6 min · SQL — Joins & Relationships
What is this?
FULL OUTER JOIN returns rows when either side matches. Unmatched left or right rows appear with NULLs on the other side.
Why should you care?
Data reconciliation — compare two lists (source vs target) and see extras on either side in one pass.
See it live — copy this example
Run in SQL Server Management Studio (SSMS) or Azure Data Studio.
USE DataVerse;
IF OBJECT_ID(N'dbo.PosSales', N'U') IS NOT NULL DROP TABLE dbo.PosSales;
IF OBJECT_ID(N'dbo.OnlineSales', N'U') IS NOT NULL DROP TABLE dbo.OnlineSales;
CREATE TABLE dbo.PosSales (Sku VARCHAR(32) PRIMARY KEY, Qty INT);
CREATE TABLE dbo.OnlineSales (Sku VARCHAR(32) PRIMARY KEY, Qty INT);
INSERT INTO dbo.PosSales VALUES ('A', 5), ('B', 2);
INSERT INTO dbo.OnlineSales VALUES ('B', 3), ('C', 4);
SELECT
COALESCE(p.Sku, o.Sku) AS Sku,
p.Qty AS PosQty,
o.Qty AS OnlineQty
FROM dbo.PosSales AS p
FULL OUTER JOIN dbo.OnlineSales AS o ON o.Sku = p.Sku;
What happened?
- Sku A is POS-only, C is online-only, B is both.
- FULL OUTER JOIN surfaces all three cases for a stock sync review.
Practice next
- Create the two sales tables and run the join.
- Identify rows where PosQty IS NULL or OnlineQty IS NULL.
- Add a computed difference column ISNULL(o.Qty,0) - ISNULL(p.Qty,0).
- Filter WHERE p.Sku IS NULL OR o.Sku IS NULL for mismatches only.
- Add a third channel table later with a different pattern.
Remember
FULL OUTER keeps unmatched rows from both sides. Great for reconcile / diff reports. COALESCE the business key in the SELECT list.
POS vs online qty reconcile
Nightly job diffs DataVerse POS and online quantities.
Outcome: Ops investigates SKUs present in only one channel.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!