Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

Checking sequence of numbers and populate a flag if number is out of sequence - response (4) by rajeev saravanan

$
0
0
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

Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>