JSON状态提取 – Metabase SQL查询

huangapple go评论62阅读模式
英文:

JSON Status Extract - Metabase SQL query

问题

我正在尝试提取“outgoing” JSON 字段中冒号后面的值,即“processing”和“cancelled”。

英文:

i have this table in metabase

id status outgoing
1 paid {"a945248027_14454878":"processing"}
2 unpaid {"old.a945248027_14454878":"cancelled"}

i am trying to extract the value after colon in the "outgoing" json field i.e processing, cancelled"

答案1

得分: 0

你可以使用 substring from 来实现:

select id, status, substring(outgoing::varchar from '':"([a-z]*)' )
from mytable t

示例在这里

英文:

You can do it using substring from :

select id, status, substring(outgoing::varchar from ':"([a-z]*)' )
from mytable t

Demo here

huangapple
  • 本文由 发表于 2023年2月9日 02:50:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/75390434.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定