Hi All, I have a table with student enrollment data. So in my table, each student id can have multiple rows, one row for each semester (we have three semesters per academic year). So a student can enroll in Fall 2015, and his enrollment ends in Summer 2019, so there will be 12 terms and potentially 12 rows in the table. However, if the student does not enroll in 5 terms in between, the table will have only 7 rows. I need to create the 5 missing rows based on the data from the row above for that student id (UID), so I have all 12 rows for that student. I have a column orig_row in the table which has all values as 1. When I copy the row, I need to mark this particular column value as 0 so I know that this row was copied from the previous row.. I have a second table with Time_periods that I can use as a lookup for missing semesters. So my data table looks like following: If a student enrolled only for one semester as uid2, then it will have only one row. Dept Residency_Type UID NewUId EndUId Uidchange Time_Period OrigRow Health 2-Out-of-State U1 1 0 New Uid 15-Sep-15 1 Health 2-Out-of-State U1 0 0 Enrolled 15-Jan-16 1 Health 2-Out-of-State U1 0 0 Enrolled 15-Jan-17 1 Health 2-Out-of-State U1 0 1 End Uid 15-Sep-17 1 Science 1-In-State U2 1 1 End Uid 15-Jan-13 1 A&L 1-In-State U3 1 0 New Uid 15-May-10 1 A&L 1-In-State U3 0 0 Enrolled 15-Sep-10 1 A&L 1-In-State U3 0 0 Enrolled 15-May-11 1 A&L 1-In-State U3 0 0 Enrolled 15-Sep-12 1 A&L 1-In-State U3 0 0 Enrolled 15-Jan-13 1 A&L 1-In-State U3 0 1 End Uid 15-May-14 1 And I want it to look like below Dept Residency_Type UID NewUId EndUId Uidchange Time_Period OrigRow Health 2-Out-of-State U1 1 0 New Uid 15-Sep-15 1 Health 2-Out-of-State U1 0 0 Enrolled 15-Jan-16 1 Health 2-Out-of-State U1 0 0 Enrolled 15-May-16 0 Health 2-Out-of-State U1 0 0 Enrolled 15-Sep-16 0 Health 2-Out-of-State U1 0 0 Enrolled 15-Jan-17 1 Health 2-Out-of-State U1 0 0 Enrolled 15-May-17 0 Health 2-Out-of-State U1 0 1 End Uid 15-Sep-17 1 Science 1-In-State U2 1 1 End Uid 15-Jan-13 1 A&L 1-In-State U3 1 0 New Uid 15-May-10 1 A&L 1-In-State U3 0 0 Enrolled 15-Sep-10 1 A&L 1-In-State U3 0 0 Enrolled 15-Jan-11 0 A&L 1-In-State U3 0 0 Enrolled 15-May-11 1 A&L 1-In-State U3 0 0 Enrolled 15-Sep-11 0 A&L 1-In-State U3 0 0 Enrolled 15-Jan-12 0 A&L 1-In-State U3 0 0 Enrolled 15-May-12 0 A&L 1-In-State U3 0 0 Enrolled 15-Sep-12 1 A&L 1-In-State U3 0 0 Enrolled 15-Jan-13 1 A&L 1-In-State U3 0 0 Enrolled 15-May-13 0 A&L 1-In-State U3 0 0 Enrolled 15-Sep-13 0 A&L 1-In-State U3 0 0 Enrolled 15-Jan-14 0 A&L 1-In-State U3 0 1 End Uid 15-May-14 1 I am new to programming and I tried to use set, merge, crossjoin, outer join etc but not able to get this result. Thank you.
... View more