SELECT a.hash, b.hash FROM layers a FULL JOIN layers b ON a.overlay_handle = b.overlay_handle ORDER BY 1, 2;