Fix sql for marking data