postgresql之greenplum字符串去重拼接方式(post过去分词)学到了

随心笔谈12个月前发布 admin
89 0



目录postgresql greenplum字符串去重拼接postgresql字符串处理方式关于查找字符串字符串与数字的相互转换总结

pg 、gp 实现 collect_set  效果:

array_agg(DISTINCT $columnName))
array(SELECT DISTINCT ? $columnName ?from $tableName )

字符串拼接 :

array_to_string(array_agg(DISTINCT ), ‘|’)?
select position(‘hello’ in ‘test_sql’)?
output:0
select position(‘test’ in ‘test_sql’)?
output:1

故可用position(str_1 in str_2) !=0判断str_1是否是str_2的子串。

字符串->数字

to_number(block_id,’999999′)和cast(block_id as numeric),但前一句会限定的数字大小为10的5次方,即过大的数值会出问题,而后一句不会。

数字->字符串

cast(block_id as varchar)将数值型转为字符串型。

以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。

您可能感兴趣的文章:PostgreSQL 使用raise函数打印字符串postgreSQL 数字与字符串类型转换操作解决postgresql 数字转换成字符串前面会多出一个空格的问题

© 版权声明

相关文章