【问题标题】:How to add double quotes for Varchar values with Columns and Values from Snowflake DB如何使用 Snowflake DB 中的列和值为 Varchar 值添加双引号
【发布时间】:2022-07-20 22:11:33
【问题描述】:

在读取 Snowflake DB 时,我需要读取 Varchar 字段的列和值。类似于以下内容:select varchar_col1, varchar_col2, numeric_col3 from my_table

varchar_col1          varchar_col2             numeric_col3
 
test_value1           test_value2                 99999

我想输出如下内容:

"varchar_col1"       "varchar_col2"         numeric_col3

 "test_value1"        "test_value2"             99999

有可能实现这样的目标吗?我尝试了各种方法,但无法做到。例如,我尝试使用这个Snowflake: SELECT "COLUMN" with double quotes

【问题讨论】:

    标签: sql snowflake-cloud-data-platform snowflake-schema


    【解决方案1】:

    这可能对你有用。

    select '"' ||  varchar_col1 as varchar_col1 , '"' ||  varchar_col2 || '"' as varchar_col2, '"' ||  numeric_col3 || '"' as numeric_col3
    from (                         
     select  column1 as varchar_col1, column2 as varchar_col2, column3 as numeric_col3 from values
    ('test_value1', 'test_value2',99999)
      );
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-04
      • 2022-01-19
      • 2013-08-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多