I have data in a Hive table as given below.
Table 1:
ID CODE VALUE
1 XXXX 100
2 AAAA 200
1 YYYY 300
3 DDDD 300
4 BBBB 200
2 CCCC 300
3 HHHH 200
I have to select ID, VALUE from Table 1 and load into Table 2.Since Table 1 has duplicate ID's, i have to get unique rows from Table 1 based on the data in CODE Field.
order of selection of rows from table 1 is first priority to be given to CCCC, then to XXXX, then to AAAA and so on.
I am expecting Table 2 to have data like below-
ID VALUE
1 100
2 300
3 300
4 200