Fixed formatting issues, improved SQL query for DM job