re constract sql for export data