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

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 27759

Trending Articles