Fixed some SQL