SELECT a.hash, b.hash, a.package_name FROM layers a JOIN layers b ON a.os_key = b.os_key AND a.arch = b.arch AND a.hash < b.hash ORDER BY 1, 2;