0
← Exercises/
Joins•11 of 12
JoinsIntermediatePRO

Abandoned Cart Sessions & Lost GMV

Scenario

Growth marketers want to run email retargeting sequences for high-intent shoppers who added items to their shopping cart but never completed checkout.

Task
Join `checkout_sessions` with `completed_purchases` using a `LEFT JOIN` on `session_id`. Find all abandoned sessions where: - `p.order_id IS NULL` - `s.cart_total_usd >= 100.00` Return: 1. `s.session_id` 2. `s.user_email` 3. `s.cart_total_usd` 4. `s.cart_item_count` Order results by `s.cart_total_usd` descending.
Expected Output Format

High-value abandoned cart sessions with cart value >= $100.

Input Tables & Sample Data0 tables
Loading database schema...
Need a hint?
query.sql|Local Sandbox
Loading SQL editor...
Click "Run" or press ⌘ + Enter to execute your query

About the “Abandoned Cart Sessions & Lost GMV” SQL Problem

Business Scenario

Growth marketers want to run email retargeting sequences for high-intent shoppers who added items to their shopping cart but never completed checkout.

Expected Output & Criteria

High-value abandoned cart sessions with cart value >= $100.

Database Table Schema (PostgreSQL DDL)

PostgreSQL 16 WASM

This challenge executes directly against the following relational schema in your browser:

CREATE TABLE checkout_sessions (
        session_id VARCHAR(20) PRIMARY KEY,
        user_email VARCHAR(100) NOT NULL,
        cart_total_usd NUMERIC(10, 2) NOT NULL,
        cart_item_count INT NOT NULL
      );

      CREATE TABLE completed_purchases (
        order_id INT PRIMARY KEY,
        session_id VARCHAR(20) REFERENCES checkout_sessions(session_id),
        paid_amount NUMERIC(10, 2) NOT NULL
      );

Target SQL Clauses & Operators

LEFT JOINIS NULLORDER BY

Want more Joins practice?

Explore the full syllabus of 12 exercises, syntax guides, and interview pitfalls.

View Joins Track→