Fixed another bracket issue in SQL query (#1099)