Question: Is there a way to automatically generate rows with different dates, but keep the rest of the data the same?

For example, I'm trying to generate the below once every 7 weeks? Is there a keen way to do this, or should I repeat the below manually?

```
INSERT INTO courses ( CourseCode ,OrganiserID ,TopicID ,StartDate ,EndDate ,Week ,LocationID ,CourseFee )

SELECT 'TEMP',9,51,'2018-01-22','2018-01-26',4 -- Week ,2,CourseFee FROM topic WHERE TopicID=51;

```

Answer: 
You can simply use `GROUP BY` and `MAX`:

```
SELECT   t.PK_DocumentInstanceChapterExpanded  
       , MAX(t.StatusColumn)
FROM     (
    SELECT     PK_DocumentInstanceChapterExpanded  
             , STATUSFLAG
    FROM       SECTION_TABLE1
    WHERE      PK_DocumentInstanceChapterExpanded = 50734 
    UNION
    SELECT     s.PK_DocumentInstanceChapterExpanded
               i.STATUSFLAG
    FROM       SECTION_TABLE s     
    INNER JOIN ITEM_TABLE i 
            ON i.FK_SECTIONKEY = s.PK_SECTIONKEY  
    WHERE      s.PK_DocumentInstanceChapterExpanded = 50734 
   ) t
GROUP BY t.PK_DocumentInstanceChapterExpanded

```

This will work because `PARTIAL` is greater in alphabetical order than `LOCKED`.
Now I don't know how many rows there could be per table per id. But if there can be only 1 why don't you just write:

```
SELECT s.PK_DocumentInstanceChapterExpanded
 ,case when i.STATUSFLAG is not null then i.STATUSFLAG else s.STATUSFLAG end
FROM SECTION_TABLE s
LEFT JOIN ITEM_TABLE i ON i.FK_SECTIONKEY = s.PK_SECTIONKEY     
WHERE s.PK_DocumentInstanceChapterExpanded=50734

```