Snowflake 中将十进制(基数 10)数字更改为不同基数(不是二进制、八进制或六进制)的功能是什么?
What is the function in Snowflake to change a decimal (base 10) number to a different base (not binary, octa or hexa)?
我想在 Snowflake 中将一个数字从十进制(基数 10)转换为基数 18。
我可以使用 to_base
函数在 Oracle SQL 中转换此数字:
十进制数:8581597126547800
使用的函数:to_base(8581597126547800,18)
18进制数的输出为7798G1GG5HGE4
我可以使用 base()
函数在 Excel 中转换此数字:
十进制数:8581597126547800
使用的函数:=base(8581597126547800,18)
18进制数的输出为7798G1GG5HGE4
Snowflake 中可以提供相同结果的函数是什么?
您可以像这样编写自己的函数:
create or replace function to_base(num double, base double)
returns varchar
language javascript
as
$$
return NUM.toString(BASE)
$$;
然后直接使用:
select to_base(8581597126547800, 18);
输出:
7798G1GG5HGE4
我想在 Snowflake 中将一个数字从十进制(基数 10)转换为基数 18。
我可以使用 to_base
函数在 Oracle SQL 中转换此数字:
十进制数:8581597126547800
使用的函数:
to_base(8581597126547800,18)
18进制数的输出为7798G1GG5HGE4
我可以使用 base()
函数在 Excel 中转换此数字:
十进制数:8581597126547800
使用的函数:
=base(8581597126547800,18)
18进制数的输出为7798G1GG5HGE4
Snowflake 中可以提供相同结果的函数是什么?
您可以像这样编写自己的函数:
create or replace function to_base(num double, base double)
returns varchar
language javascript
as
$$
return NUM.toString(BASE)
$$;
然后直接使用:
select to_base(8581597126547800, 18);
输出:
7798G1GG5HGE4