create 1st sql for report