Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Counting consecutive dates - response (2) by dnoeth

$
0
0
Yes, some more info would be helpful indeed, but this is probably what you want: select EMP_NUM, TRAN_DT, ROW_NUMBER() OVER (PARTITION BY EMP_NUM, dummy ORDER BY TRAN_DT) as consecutive_days from ( select TRAN_DT, EMP_NUM, TRAN_DT - ROW_NUMBER() OVER (PARTITION BY EMP_NUM ORDER BY TRAN_DT) as dummy from ( select distinct TRAN_DT, TRAN_TYPE, EMP_NUM from MYTABLE where TRAN_TYP = 'A' ) as dt ) as dtDieter

Viewing all articles
Browse latest Browse all 27759

Trending Articles



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