'Populating Value from table A into Table B
I have a sourcetable in which I have a field creation_date and another filed Podium_date along with other fields .
Now the business logic is if the creation_date from source table is null then the field in the target table (DW_Start_date) should be populated as Podium_date(which is a source field) can anyone help me writing the logic in Hive or SQL
Note 1: I have two tables source table and a target table and I am trying to populate the data from source table to target table
Note 2: There is no primary key in the source table This logic has to run trough all the data in the source table and should update the target table field DW_Start_date
Solution 1:[1]
If you want to populate the target field DW_Start_date from the SQL sentence you can use ISNULL(creation_date, Podium_date), this will return creation_date if it is not null, and Podium_date otherwise.
You can have a look at the sintaxis here. It would be something similar to:
INSERT INTO target_table(DW_Start_date, column2, column3, ...)
SELECT ISNULL(creation_date, Podium_date), column2, column3, ...
FROM source_table
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | mbd |
