【问题标题】:Hexa to Decimal in snowflake雪花中的十六进制到十进制
【发布时间】:2022-01-12 12:58:25
【问题描述】:
I need a query to convert hexa value to decimal value. below is the query

For 0xE7 the decimal value is 231.

How to convert hexadecimal value to decimal value in snowflake.
Below is the query I am trying to execute

选择
hexa_decode_string(concat(substr('0x00E7000101000000'::varchar,1,2), substr(replace('0x00E7000101000000'::varchar,'0x'),3,2)));

【问题讨论】:

    标签: hex


    【解决方案1】:

    你可能需要写JS UDF,下面是一个:

    create or replace function hex_to_int (input string) 
    returns double language JAVASCRIPT 
    as 
    'if (INPUT !== null)
    {
    op = parseInt(INPUT, 16);
    }
    return op';
          
    select hex_to_int('0xE7');
    

    【讨论】:

      猜你喜欢
      • 2021-09-03
      • 2011-12-09
      • 2018-07-26
      • 2011-06-01
      • 2014-08-24
      • 2016-01-05
      • 2023-03-14
      • 2023-03-19
      • 2011-02-27
      相关资源
      最近更新 更多