Wednesday, 19 May 2021

Postgresql: Find the 'N' th occurrences in a string

 Sample Table:

create table filter_table (filter_type varchar(500));

Insert Query:

insert into filter_table (filter_type) values ('1111111 > 22222 > 3333333> 4444444> 123456789 > abcdefghi > 987654321 > zyxwvuts > 0000000 >');


Query to find the occurrences:

select substring(filter_type from '^(([^ ]* ){2})')

from filter_table

No comments:

Snowflake - Cost Optimization

Reduce auto-suspend to 60 seconds Reduce virtual warehouse size Ensure minimum clusters are set to 1 Consolidate warehouses Separate warehou...