How to query software policy violators in SQL