Hi I have an interesting problem. I Have an Employee Table AS Follows
CREATE TABLE EMPLOYEE(
EMPLOYEE_ID INTEGER,
SALARY DECIMAL(18,2),
PAY_PERIOD DATE)
Now the tables have employees some of whom get paid monthly,some weekly, some biweekly and some daily. What we want is to find an Indicator saying 'Y' if the salary of three consecutive Pay Periods is equal. Lets take the following example.
Employee Pay_Period Salary
1 01/01/2012 $500
1 08/01/2012 $200
1 15/01/2012 $200
1 22/01/2012 $200
1 29/01/2012 $700
In this case the indicator should be Yes because 3 consecutive pay periods have a salary of $200.
Since the number of pay periods is not constant I am unsure of how to write this code because I do not know from before hand how many left joins I will need.Since I am writing this in Teradata I tried using the RECURSIVE Function but got stumped. Any general ideas on how to proceed with this?I would prefer not creating a stored procedure or having PL/SQL logic.