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

bookChallenge: Unmatched Records Report

Oppgave

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.

Løsning

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 6
single

single

Spør AI

expand

Spør AI

ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

close

bookChallenge: Unmatched Records Report

Sveip for å vise menyen

Oppgave

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.

Løsning

Switch to desktopBytt til skrivebordet for virkelighetspraksisFortsett der du er med et av alternativene nedenfor
Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 1. Kapittel 6
single

single

some-alt