gpt4 book ai didi

string - 如何在postgresql中获取一列字符串的字符串长度

转载 作者:行者123 更新时间:2023-11-29 13:17:03 24 4
gpt4 key购买 nike

给定文本/字符串列的输入,我想计算列中字符串的长度,以及每个长度的计数。

例如包含字符串的列:

'Ant'
'Cat'
'Dog'
'Human'
''
NULL
'A human'

会给出:

0 : 1
3 : 3
5 : 1
7 : 1

注意:空字符串没有算作 0 字符串,而是被忽略了。

最佳答案

length() 浮现在脑海中:

select length(col), count(*)
from t
where col is not null
group by length(col)
order by length(col);

关于string - 如何在postgresql中获取一列字符串的字符串长度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47659329/

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