gpt4 book ai didi

amazon-redshift - SQL Server isNumeric() 在 amazon redshift 中等效

转载 作者:行者123 更新时间:2023-12-03 21:08:20 25 4
gpt4 key购买 nike

  • 我使用 amazon redshift 作为我的数据仓库
  • 我有一个字符串类型的字段 (field1)。有些字符串以四个数字开头,有些以字母开头:

  • '测试阿尔法'
    '1382 测试版'
  • 我想过滤掉字符串不以四个数字开头的行
  • 查看 redshift 文档,我不相信 isnumber 或 isnumeric 是函数。似乎“喜欢”功能是最好的可能性。
  • 我试过

    其中 left(field1, 4) 像 '[0-9][0-9][0-9][0-9]'

  • 这不起作用,从下面的链接看来,redshift 可能不支持:

    https://forums.aws.amazon.com/message.jspa?messageID=439850

    “where”子句中是否有错误?如果不是,并且 redshift 不支持该子句,有没有办法过滤?我在考虑使用类型转换
    cast(left(field1,4) as integer) 

    然后在产生错误时传递该行,但不确定如何在亚马逊 Redshift 中执行此操作。或者 isnumeric 过滤器是否有其他一些代理。

    谢谢

    最佳答案

    尝试类似:

    where field1 ~ '^[0-9]{4}'

    它将匹配任何以 4 位数字开头的字符串。

    关于amazon-redshift - SQL Server isNumeric() 在 amazon redshift 中等效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16948323/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com