I have 2 columns I want to convert to varchars and concatenate to place them in one column:
How would I do this in Hive? I keep getting issues when I try 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:
This worked for me.....
concat('$',cast(round(min(temp)) as string), ' - $', cast(round(max(temp)) as string)) over (partition by temp2, temp3) newColumn
Try this:
select ('$' || round(min(temp) over (partition by temp2, temp3) || '-' ||
'$' || round(max(temp)) over (partition by temp2, temp3)
) as minmax
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With