hello99hello
Programmer
Hello All, I am trying to write sql to achive the following.
I have a table1 with the following columns:
Employee ID
Name
Plan
Type
Sample of records in the table are the following:
2067,Janice,LIFE,Y -------record 1
2067,Janice,MSP,Y -------record 2
2045,Enry,LIFE,Y -------record 3
2045,Enry,OPT,N -------record 4
2345, Louis,MSP,N -------record 5
2345, Louis,OPT,N -------record 6
My goal is to select all records in table1 and insert them in table2 of the same structure. Also, if column Type = 'Y', additional duplicate of record 1 is to be added to table2 for a distinct (once for 2067 and once for 2045) value of column Employee ID, let us call new record 1d.
Lastly, values of columns Name and Plan in record id are to change e.g. from Janice Janice2 and LIFE to EHP LIFE.
Hence, the records in table2 could look like:
2067,Janice,LIFE,Y -------record 1
2067,Janice2,EHP LIFE,Y -------record 1d
2067,Janice,MSP,Y -------record 2
2045,Enry,LIFE,Y -------record 3
2045,Enry2, EHP LIFE,Y -------record 3d
2045,Enry,OPT,N -------record 4
2345, Louis,MSP,N -------record 5
2345, Louis,OPT,N -------record 6
Please any help would be appreciated.
I have a table1 with the following columns:
Employee ID
Name
Plan
Type
Sample of records in the table are the following:
2067,Janice,LIFE,Y -------record 1
2067,Janice,MSP,Y -------record 2
2045,Enry,LIFE,Y -------record 3
2045,Enry,OPT,N -------record 4
2345, Louis,MSP,N -------record 5
2345, Louis,OPT,N -------record 6
My goal is to select all records in table1 and insert them in table2 of the same structure. Also, if column Type = 'Y', additional duplicate of record 1 is to be added to table2 for a distinct (once for 2067 and once for 2045) value of column Employee ID, let us call new record 1d.
Lastly, values of columns Name and Plan in record id are to change e.g. from Janice Janice2 and LIFE to EHP LIFE.
Hence, the records in table2 could look like:
2067,Janice,LIFE,Y -------record 1
2067,Janice2,EHP LIFE,Y -------record 1d
2067,Janice,MSP,Y -------record 2
2045,Enry,LIFE,Y -------record 3
2045,Enry2, EHP LIFE,Y -------record 3d
2045,Enry,OPT,N -------record 4
2345, Louis,MSP,N -------record 5
2345, Louis,OPT,N -------record 6
Please any help would be appreciated.