fix sql for select