Hi Sagar,
You can try the following query as well, this should work with duplicates also
It will just increase the filecount
Here tab id the table which contains the data
Please try and let me know if this works
sel
Serial_Number
,Send_Date
,max(cnt) file_count
,case when max(diff) > 1 then 'Yes' else 'No' end as Non_Seq_Flag
,max(file_number) as Min_Seq
,min(file_number) as Max_Seq
from
(
sel
Serial_Number
,Send_Date
,File_Number
,count(*) over (partition by Serial_Number,Send_Date order by file_number)as cnt
,coalesce(mdiff(file_number,1,file_number),0) as diff
from
tab
group by 1,2
)a
group by 1,2
order by 1,2;
Regards
Rajeev
↧