Challenge: Unmatched Records Report
Uppgift
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ösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 6
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Fantastiskt!
Completion betyg förbättrat till 4.76
Challenge: Unmatched Records Report
Svep för att visa menyn
Uppgift
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ösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 1. Kapitel 6
single