PGSQL下的常用函數


1、COALESCE — 空值替換函數。
ExportDocumenttaskMapper.xml.listBusiInfos4Export                    ---coalesce(cbi.valid_month, '999999')
IntegrationPointConfigMapper.xml.getIntegrationPointConfigList         ---round(coalesce(pc.deduction_value,0) * 100,2)||'%'
2、regexp_split_to_table — 行專列
示例:regexp_split_to_table(col, 'splitor'):如果某條記錄的col列的值為‘1,2,3,4,5',而splitor為',',則結果是:該條記錄被轉換成5條記錄,且各條記錄的col列的值依次為1、2、3、4、5
select * from regexp_split_to_table('kenyon,love,1,china,!',',');
CmNowManagerCommissionMapper.xml.selectAllCommission
3、regexp_split_to_array


select string_to_array('1,2,3,4,5,6',',') arr from dual;
select regexp_split_to_array('1,2,3,4,5,6',',') arr from dual;
select * from regexp_split_to_array('1,2,3,4,5,6',',');
select regexp_split_to_table('1,2,3,4,5,6',',') bb from dual;
select * from dual where '1' in (select * from regexp_split_to_table('1,2,3,4,5,6',','));

 select * from dual where '1' in (SELECT
            UNNEST (
                regexp_split_to_array('1,2,3,4,5,6',',')
            ));
 select * from dual where '1' in (SELECT
            UNNEST (
                string_to_array('1,2,3,4,5,6',',')
            ));
UNNEST--表示把array類型展開成多行
string_to_array和regexp_split_to_array效果基本一致
CommBilloneApplReview_Column_List
regexp_split_to_array(d.business_type,',')@>array[t.businessType || '']


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM