select * from (select ,ROW_NUMBER() over (Partition by FLAG ORDER By temp4.do_not_file) as Row_number from" + "(select temp2.REFERENCE_FLOW_ID,temp2.PUBLICATIO