Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Unmatched Records Report | Core Join Types and Their Applications
SQL Joins in Depth

bookChallenge: Unmatched Records Report

Task

Swipe to start coding

Write a SQL query that uses FULL OUTER JOIN to list all customers and all orders, showing which customers do not have any orders and which orders do not have a matching customer.

  • Join the customers and orders tables using a FULL OUTER JOIN on the customer_id field.
  • Select the customer_id and name from the customers table, and the order_id and order_date from the orders table.
  • Add a column named match_status that indicates:
    • 'Customer without orders' if the customer has no matching order.
    • 'Order without customer' if the order has no matching customer.
    • 'Matched' if both customer and order exist.
  • Order the results so that unmatched records appear first, followed by matched records.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 6
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: Unmatched Records Report

Swipe to show menu

Task

Swipe to start coding

Write a SQL query that uses FULL OUTER JOIN to list all customers and all orders, showing which customers do not have any orders and which orders do not have a matching customer.

  • Join the customers and orders tables using a FULL OUTER JOIN on the customer_id field.
  • Select the customer_id and name from the customers table, and the order_id and order_date from the orders table.
  • Add a column named match_status that indicates:
    • 'Customer without orders' if the customer has no matching order.
    • 'Order without customer' if the order has no matching customer.
    • 'Matched' if both customer and order exist.
  • Order the results so that unmatched records appear first, followed by matched records.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 6
single

single

some-alt