Fix sql qery.