2017-12-05 8 views
1

テキスト/文字列の入力が与えられた場合、列内の文字列の長さと各長さの数を計算します。postgresqlの文字列の列の文字列長の取得方法

など。文字列と列:

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

を与えるだろう:

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

注:ヌル文字列が0の文字列として数えますが、無視されていません。

答えて

1

length()が頭に浮かぶ:

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

おかげで、今、これをしよう – dahui

関連する問題