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

Compare 3 Consecutive rows in a table - response (3) by dnoeth

$
0
0
This is a direct translation of your narrative, it will return 'Y' starting with the 3rd consecutive row: CASE WHEN salary = MIN(salary) OVER (PARTITION BY employee_id ORDER BY pay_period ROWS BETWEEN 1 PRECEDING AND 1 PRECEDING) AND salary = MIN(salary) OVER (PARTITION BY employee_id ORDER BY pay_period ROWS BETWEEN 2 PRECEDING AND 2 PRECEDING) THEN 'Y' ELSE 'N' END Dieter  

Viewing all articles
Browse latest Browse all 14773

Trending Articles



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