I found this one which will give DNs which are shared. But doesn't list the device. I assume maybe would have to join it with d.name from device table but not exactly sure how.
run sql select numplan.dnorpattern, routepartition.name, count(*) from ...