Write SQL Query 2
Exercise
Correct!
SELECT i.Id, i.BillingDate, c.Name, r.Name AS ReferredByName
FROM Invoices i
code_here Customers c ON i.CustomerId = c.Id
code_here Customers r ON c.ReferredBy = r.Id
ORDER BY i.BillingDate
SELECT i.Id, i.BillingDate, c.Name, r.Name AS ReferredByName FROM Invoices i LEFT JOIN Customers c ON i.CustomerId = c.Id LEFT JOIN Customers r ON c.ReferredBy = r.Id ORDER BY i.BillingDate
assert(line2 == l2); assert(line3 == l3);
function rpls(str){ return str.toLowerCase().replace(/'/g,'').replace(/ /g, ''); } var l2 = rpls("LEFT JOIN Customers c ON i.CustomerId = c.Id"); var l3 = rpls("LEFT JOIN Customers r ON c.ReferredBy = r.Id");