‹ Tests

Databases & SQL Practice Test 1

1 / 10

Joinshard

A report must list every customer, with the id of their paid order if they have one and NULL otherwise. The data is:

customers(id, name): (1, 'Ana'), (2, 'Ben'), (3, 'Cai')

orders(id, customer_id, status): (10, 1, 'paid'), (11, 1, 'refunded'), (12, 2, 'refunded')

The current query is SELECT c.name, o.id FROM customers c LEFT JOIN orders o ON o.customer_id = c.id WHERE o.status = 'paid'; and it returns only one row, Ana with order 10. Which change makes the query return exactly Ana/10, Ben/NULL and Cai/NULL?

Select one answer

0 / 10 answered