Hive - convert Int to varchar and concatenate

I have 2 columns that I want to convert to varchars and concatenate to fit them in one column:

How can I do this in Hive? I keep getting problems when I try in the normal way in sql ...

round(min(temp) over (partition by temp2, temp3) min,
round(max(temp)) over (partition by temp2, temp3) max

*original columns*
min    max
 0    100

      

=====================================

*new column*
min-max
$0-$100

      

Answer:

It worked for me .....

concat('$',cast(round(min(temp)) as string), ' - $', cast(round(max(temp)) as string)) over (partition by temp2, temp3) newColumn

+3


source to share


1 answer


Try the following:



select ('$' || round(min(temp) over (partition by temp2, temp3) || '-' ||
        '$' || round(max(temp)) over (partition by temp2, temp3)
       ) as minmax

      

0


source







All Articles