Postgresql之split_part()切割函数
SELECT COUNT (*) AS "count",
split_part(tree_t.node_path, "|", 2) AS "id",
name_t.node_name AS "type"
FROM datsvc_data_standard_t sd_t
INNER JOIN datsvc_tree_t tree_t ON tree_t."id" = sd_t.tree_category
INNER JOIN datsvc_tree_t name_t ON name_t."id" :: VARCHAR = split_part(tree_t.node_path, "|", 2)
WHERE tree_t."type" = 2
GROUP BY split_part(tree_t.node_path, "|", 2),
name_t.node_name
split_part(string text, delimiter text2, field int)
text要切割的字段; text2按照什么形式切割 int截取的位置
ps:
text=“a.b.c” split_part(text,’.’,1) 结果: a
text=“a.b.c” split_part(text,’.’,2) 结果: b
text=“a.b.c” split_part(text,’.’,3) 结果: c
以上是 Postgresql之split_part()切割函数 的全部内容, 来源链接: utcz.com/z/532643.html