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 (8) by rajeev saravanan

$
0
0
Hi Sagar Pls try the following query for your additional requirement Sel Send_Date ,sum(file_count) ,max(Non_Seq_Flag) from (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 )b group by 1 order by 1; let me know if this works Also you can learn about the analytical functions here - http://www.coffingdw.com/sql/tdsql.htm refer to chapter 10 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>