I had the need to count an occurrence of a specific character in a string and after tossing some ideas back and forth between a couple of my colleges, we came up with the below two SQLs. You pass a string and identify the character you are looking to count its occurrence. In both SQLs below, I'm trying to count how many times does ">>" exists in string "This is>>a string>>to look into>>". The answer of course is 3 times.
SQL Option 1:
SQL Option 2:
I personally prefer option 2. Do you have a better way of achieving the same result? Please share it in the comments section below if you do!
Title | Under | Posted on |
---|---|---|
Component interface Error: no rows exist for the specified keys | PeopleSoft Technical | 03/15/2019 - 3:54am |
ADD 24 months starting from current month.(peoplesoft) | PeopleSoft Functional | 07/29/2018 - 8:44pm |
TRC values dropdown | PeopleSoft Technical | 04/04/2018 - 12:54am |
how to find missing sequence in GRID and print the mising sequence number while saving through peoplecode | PeopleSoft Technical | 09/11/2017 - 4:49am |
Recent comments
2 years 23 weeks ago
2 years 28 weeks ago
2 years 28 weeks ago
2 years 29 weeks ago
2 years 30 weeks ago
2 years 30 weeks ago
2 years 32 weeks ago
2 years 34 weeks ago
2 years 37 weeks ago
2 years 42 weeks ago