Do you know how to format the output of a number in hive with thousand separator? For example:
data:146452664
output:146,452,664
I use this in Teradata, but don't know how to achieve in Hive.
cast(cast(cast(number as integer) as format'ZZZ,ZZZ,ZZZ,ZZ9') as char(11))
The convert function can put the thousands separator in for you, but only if you are converting from the Money data type to the varchar data type. You also need to use the optional 3rd parameter of the convert function.
In SQL Server, you can use the T-SQL FORMAT() function to format a number as a currency. The FORMAT() function allows you to format numbers, dates, currencies, etc. It accepts three arguments; the number, the format, and an optional “culture” argument.
Use the format_number()
function.
select format_number(146452664,0)
The first argument is the number and second is the number of decimal places to round.If D is 0, the result has no decimal point.
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