The below query will work with duplicates along with null values if we have it in File number too..
sel
Serial_Number,
Send_Date ,
Count(*) as File_Count ,
Case When ( Max_Seq - Min_Seq ) = File_Count-1 Then ' No' Else 'YES' END as Non_Seq_Flag,
Min (File_Number) as Min_Seq,
max( File_Number) as Max_Seq
from
( sel distinct serial_number,send_date,zeroifnull(File_number) as File_number from <<sourcetable>>)dt
group by
Serial_Number,
Send_Date
Regards,
Mohan K
↧