Bonus: Each Order With Customer Name and Payment Amount
SQL coding challenge · Difficulty: medium · +100 XP
Problem
The order management system needs each order with the customer name and payment amount. Show all orders — even those with no payment.
Tables
Table: Customers
| customer_id | name | city | | --- | --- | --- | | 1 | Abha | Delhi | | 2 | Parvati | Mumbai | | 3 | Pinki | Bangalore | | 4 | Krishna | Chennai |
Table: Orders
| order_id | customer_id | order_date | | --- | --- | --- | | 101 | 1 | 2024-05-01 | | 102 | 1 | 2024-05-05 | | 103 | 2 | 2024-05-03 | | 104 | 3 | 2024-05-07 | | 105 | 4 | 2024-05-10 |
Table: Payments
| payment_id | order_id | amount | | --- | --- | --- | | 201 | 101 | 2800.00 | | 202 | 102 | 1500.00 | | 203 | 103 | 3200.00 | | 204 | 104 | 2100.00 | | 205 | 106 | 1900.00 |
Expected Output
| order_id | order_date | name | payment_amount | | --- | --- | --- | --- | | 101 | 2024-05-01 | Abha | 2800.00 | | 102 | 2024-05-05 | Abha | 1500.00 | | 103 | 2024-05-03 | Parvati | 3200.00 | | 104 | 2024-05-07 | Pinki | 2100.00 | | 105 | 2024-05-10 | Krishna | NULL |
- Return:
order_id,order_date,customer_name,payment_amount - Orders with no payment → NULL for payment_amount
- Sort by
order_idascending