Goal view: SQL query fix