SQL fix towards new input