Interview Questions _Hive

Convert Values Negative to Positive & positive to Negative


hive> select * from mhtprabhu.tablefortest;

56
-74
15
-51
-9
32

Ans:

set hive.cli.print.header=true;

SELECT CASE WHEN ( Col_name> 0 ) THEN (Col_name*-1) else (Col_name*-1) end as converted_values froM mhtprabhu.tablefortest;

-56
74
-15
51
9
-32