sql minor bug