Exercise · SQL & Querying
Predict, then run it
Predict the output
carts(cart, zone_id) = (c1,10),(c2,NULL),(c3,20),(c4,NULL). zones(zone_id, zone) = (10,North),(20,South). Show every cart, the zoneless ones as 'Unassigned':
SELECT c.cart, COALESCE(z.zone, 'Unassigned') AS zone FROM carts c LEFT JOIN zones z ON z.zone_id = c.zone_id ORDER BY c.cart;
Predict the exact output.