Challenge: Unmatched Records Report
Aufgabe
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
customersandorderstables using aFULL OUTER JOINon thecustomer_idfield. - Select the
customer_idandnamefrom thecustomerstable, and theorder_idandorder_datefrom theorderstable. - Add a column named
match_statusthat 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ösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 1. Kapitel 6
single
Fragen Sie AI
Fragen Sie AI
Fragen Sie alles oder probieren Sie eine der vorgeschlagenen Fragen, um unser Gespräch zu beginnen
Suggested prompts:
Can you explain that in more detail?
What are the main benefits or drawbacks?
Can you give me an example?
Großartig!
Completion Rate verbessert auf 4.76
Challenge: Unmatched Records Report
Swipe um das Menü anzuzeigen
Aufgabe
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
customersandorderstables using aFULL OUTER JOINon thecustomer_idfield. - Select the
customer_idandnamefrom thecustomerstable, and theorder_idandorder_datefrom theorderstable. - Add a column named
match_statusthat 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ösung
War alles klar?
Danke für Ihr Feedback!
Abschnitt 1. Kapitel 6
single