Fixed sql query.