I want to use Group_ID as the primary key in all of my tables. Unfortunately, the uploaded data has group IDs from two systems: OLD_ID and NEW_ID. Ultimately, all groups will have a NEW_ID number, but for now, some do and some don't. This means that some groups only have OLD_ID, some have both NEW_ID and OLD_ID, and some only have NEW_ID.
What I want to do is pull the information from NEW_ID and OLD_ID into a new field in a separate table, GROUP_ID (the new field is also called Group_ID). The logic I want goes like this:
IF NEW_ID is not blank, use NEW_ID; ELSE use OLD_ID.
In the original table, there would be no primary key, since both OLD_ID and NEW_ID have null values in some records. Both of these fields would link to primary key Group_ID in the GROUP_ID table, and all other tables would link to Group_ID via that table as well.
My restrictions are that I can't change anything in the uploaded data, and that I only want to pull up one of the ID numbers (in the event that a group has both).
My questions:
(1) Is this possible to do?
(2) If it is possible, what is the SQL code and where would I put it?
(3) If it is not possible, are there other solutions?
What I want to do is pull the information from NEW_ID and OLD_ID into a new field in a separate table, GROUP_ID (the new field is also called Group_ID). The logic I want goes like this:
IF NEW_ID is not blank, use NEW_ID; ELSE use OLD_ID.
In the original table, there would be no primary key, since both OLD_ID and NEW_ID have null values in some records. Both of these fields would link to primary key Group_ID in the GROUP_ID table, and all other tables would link to Group_ID via that table as well.
My restrictions are that I can't change anything in the uploaded data, and that I only want to pull up one of the ID numbers (in the event that a group has both).
My questions:
(1) Is this possible to do?
(2) If it is possible, what is the SQL code and where would I put it?
(3) If it is not possible, are there other solutions?
Comment